1

xlWorkBook.SaveAs("C:\examples\employee.xls", Excel.XlFileFormat.xlWorkbookNormal, misValue, misValue, misValue, misValue, Excel.XlSaveAsAccessMode.xlExclusive, misValue, misValue, misValue, misValue, misValue);

In the above relation why do we write most of the misvalue . please explain, Thanks in Advance

3
  • How is this related to C, C#, or SQL? It seems that the code you show is VBA. Please don't spam with unrelated tags. Also please take some time to read the help pages, take the SO tour, read How to Ask, as well as this question checklist. Commented Mar 12, 2020 at 9:39
  • 1
    This question looks like valid C# to me.
    – Polyfun
    Commented Mar 12, 2020 at 9:41
  • @Polyfun Even with those backslashes in the string? Commented Mar 12, 2020 at 9:48

1 Answer 1

2

You are calling a COM component (Excel) using COM interop. COM is a totally different (and older) framework to .Net. To help you call the COM component, .Net creates a Runtime Callable Wrapper (RCW) which is a proxy class that allows you to use managed C# code to call COM. But C# and COM implementations of optional parameters are not compatible with each other--the C# compiler does not know how to map a default C# parameter onto a default COM parameter. Thus, for default COM parameters we have to explicitly give them the System.Reflection.Missing.Value.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.