C# Error: Cannot convert 'Object' to 'Ref Object'

Provided by the FMS Development Team

In this example, with working with the Word 10.0 Object model, the method PrintOut requires the parameters to be 'ref object'.

The parameter for the PrintDocument() function requires an integer to be passed in. To provide the correct type for the Word PrintOut() method, create a local OBJECT variable and assign it to the parameter being passed in the function.

public void PrintDocument(int copiesToPrint)

{

    object _copiesToPrint = copiesToPrint;

 

    mobjWord.ActiveDocument.PrintOut(

    ref MissingValue, ref MissingValue, ref MissingValue,

    ref MissingValue, ref MissingValue, ref MissingValue,

    ref MissingValue, ref _copiesToPrint, ref MissingValue,

    ref MissingValue, ref MissingValue, ref MissingValue,

    ref MissingValue, ref MissingValue, ref MissingValue,

    ref MissingValue, ref MissingValue, ref MissingValue);

}


Additional Resources

 

 

Thank you! Thank you! I just finished reading this document, which was part of a link in the recent Buzz newsletter. I have printed it for others to read, especially those skeptical on the powers of Access and its capabilities.

Darren D.


View all FMS products for Microsoft Access All Our Microsoft Access Products

 

 

Free Product Catalog from FMS