In VB 2005, this is not really an issue because it supports optional parameters and we can just leave them out. But C# doesn't support this, so one must create object variables and pass them in.
See the following code sample:
using Microsoft.Office.Core;
using Microsoft.Office.Interop.Excel; // Must have office installed
Application NewExcelApp = new Application;
NewExcelApp.Worksheets.Add(); // This will not compile
So, as a workaround, the Type.Missing field can be used and this field can be passed in with the C# code and the application will work as expected.
Check it in the following code snippet:
using Microsoft.Office.Core;

Comments
Join the conversation! Your thoughts help the community grow.