filesaveas in c#

T

Travis

I'm getting a "The argument value is not valid." error when trying to save a
project in c#. I been trying different combinations, but I can't figure what
argument(s) is failing....a lot of them are optional, but c# requires to
specify all. Any ideas?

obj.FileSaveAs("C:\\test.MPP",
Microsoft.Office.Interop.MSProject.PjFileFormat.pjMPP, //Format
false, //Backup
false, //ReadOnly
false, //TaskInformation
false, //Filtered
"", //Table
"", //UserID
"", //DBPassword
"MSProject.MPP", //FormatID
"", //Map
"", //Password
"", //WriteResPassword
false, //ClearBaseline
false, //ClearActuals
false, //ClearResourceRates
false, //ClearFixedCosts
"", //XMLName
false //ClearConfirmed
);
 
P

PeterNZ

Hi Travis,

the FileSaveAs Method expects Object Parameters. If you use "", you pass in
a String object. This doesn't work. You also can't pass in null as Objects
are reference types and the FileSaveAs method expects an Object Reference.

The System.Reflection.Missing.Value is your best friend in this situation.
It basically creates a dummy object reference and the FileSaveAs Method is
happy. You can either use the complete path or do a "using System.Reflection"
and use Missing.Value or you define an instance object like "object missing =
System.Reflection.Missing.Value;" and just use "missing" in your method call
for each optional parameter.

HTH

Cheers

Peter
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top