After a bit of digging through COM interop help, I discovered the answer:

Use System.Reflection.Missing.Value as a stand-in for the optional argument (DOH!)

By on 6/2/2008 11:57 AM ()

According to the readme for 1.9.4.15 ("Supply Named and Optional Aruments to COM methods" [sic - "Arguments" is misspelled in the readme]), F# should now automatically handle missing arguments. I just tried it, and it seems to work for Excel 2003 (I was able to open a workbook using Application.Workbooks.Open and supplying only the filename parameter).

By on 6/2/2008 1:12 PM ()

Thanks...

This would explain why the F# compiler had no problems with omitted optional arguments. However, every time I tried executing the method call with the optional parameter omitted, my Word add-in crashed completely without an error message (even "try - with" did no good).

In the meantime, the "Missing.Value" workaround got me out of the difficulty.

By on 6/2/2008 5:06 PM ()

Hi guys,

You uncovered an issue in the F# compiler, which is now tracked in our database. Hopefully, it will be fixed in the next versions. For now, as it was pointed out, the only workaround is to pass the 'Missing Value'.

We'll make sure the spelling issue related to "argument" is fixed as well.

Please, keep reporting issue to help us deliver an outstanding product! [:)]

-Matteo (F# Team)

By on 6/3/2008 2:27 PM ()
IntelliFactory Offices Copyright (c) 2011-2012 IntelliFactory. All rights reserved.
Home | Products | Consulting | Trainings | Blogs | Jobs | Contact Us | Terms of Use | Privacy Policy | Cookie Policy
Built with WebSharper