ProjectApplication.FileSaveAs in C#

P

PeterNZ

Hi all you helpful people.

I want to export a Project to Excel, using a C# MS Project Add In I develop.
I already created a Map. I now use this function call in my code:
saveStatus =
projectApp.FileSaveAs("C:\\temp\\testproject.xls",MSProject.PjFileFormat.pjXLS,
false,false,false,false,Missing.Value,Missing.Value,Missing.Value,
Missing.Value,projectApp.ActiveProject.MapList
["testMap"],Missing.Value,Missing.Value, false,false,false,false,
Missing.Value,false);
The method gets called and return value is true. So far so good. But the
file doesn't get created. Even if I replace the file path with
"Missing.Value" I get a SaveAs Dialog, select the location and click save and
it doesn't complain about anything. But the file just isn't there. Same if I
skip the map and replace this with the Missing.Value as well. Same result.

I use MS Project 2003 Professional and work offline. Did I set a parameter
value incorrectly?

Any ideas?

Thanx

Peter
 
P

PeterNZ

One addition. I meanwhile found out that I have to use "testMap" instead of
"projectApp.ActiveProject.MapList["testMap"]".

But still no file gets saved.

Cheers

Peter
 
R

Rod Gill

Hi,

This is where VB is much faster and easier to program in!!

In Project record a macro in Project to save as you want. Copy and paste the
resultant VBA code into VB.Net and with next to no tweaks it will run. VBA
and VB allow optional parameters: you don't have to define all parameters,
the rest default to specified values (in help).

--

Rod Gill
Project MVP
Visit www.msproject-systems.com for Project Companion Tools and more


PeterNZ said:
One addition. I meanwhile found out that I have to use "testMap" instead
of
"projectApp.ActiveProject.MapList["testMap"]".

But still no file gets saved.

Cheers

Peter

PeterNZ said:
Hi all you helpful people.

I want to export a Project to Excel, using a C# MS Project Add In I
develop.
I already created a Map. I now use this function call in my code:
saveStatus =
projectApp.FileSaveAs("C:\\temp\\testproject.xls",MSProject.PjFileFormat.pjXLS,
false,false,false,false,Missing.Value,Missing.Value,Missing.Value,
Missing.Value,projectApp.ActiveProject.MapList
["testMap"],Missing.Value,Missing.Value, false,false,false,false,
Missing.Value,false);
The method gets called and return value is true. So far so good. But the
file doesn't get created. Even if I replace the file path with
"Missing.Value" I get a SaveAs Dialog, select the location and click save
and
it doesn't complain about anything. But the file just isn't there. Same
if I
skip the map and replace this with the Missing.Value as well. Same
result.

I use MS Project 2003 Professional and work offline. Did I set a
parameter
value incorrectly?

Any ideas?

Thanx

Peter
 
P

PeterNZ

Thank you Rod for your reply. Unfortunately, C#.Net is the language. There is
more going on after the save as excel file. Of course I did the macro
recording. And it works. But the problem is, we would then have to deploy a
VBA macro plus our .Net components.

Isn't there a way to get it working in C#? Must be! I still don't understand
why I don't get any feedback from the system, no exception, no eventlog entry
nothing. Even the methodcall returns true! It just doesn't save the file.

Cheers

Peter

Rod Gill said:
Hi,

This is where VB is much faster and easier to program in!!

In Project record a macro in Project to save as you want. Copy and paste the
resultant VBA code into VB.Net and with next to no tweaks it will run. VBA
and VB allow optional parameters: you don't have to define all parameters,
the rest default to specified values (in help).

--

Rod Gill
Project MVP
Visit www.msproject-systems.com for Project Companion Tools and more


PeterNZ said:
One addition. I meanwhile found out that I have to use "testMap" instead
of
"projectApp.ActiveProject.MapList["testMap"]".

But still no file gets saved.

Cheers

Peter

PeterNZ said:
Hi all you helpful people.

I want to export a Project to Excel, using a C# MS Project Add In I
develop.
I already created a Map. I now use this function call in my code:
saveStatus =
projectApp.FileSaveAs("C:\\temp\\testproject.xls",MSProject.PjFileFormat.pjXLS,
false,false,false,false,Missing.Value,Missing.Value,Missing.Value,
Missing.Value,projectApp.ActiveProject.MapList
["testMap"],Missing.Value,Missing.Value, false,false,false,false,
Missing.Value,false);
The method gets called and return value is true. So far so good. But the
file doesn't get created. Even if I replace the file path with
"Missing.Value" I get a SaveAs Dialog, select the location and click save
and
it doesn't complain about anything. But the file just isn't there. Same
if I
skip the map and replace this with the Missing.Value as well. Same
result.

I use MS Project 2003 Professional and work offline. Did I set a
parameter
value incorrectly?

Any ideas?

Thanx

Peter
 
P

PeterNZ

Problem solved! I replaced all "false" with "Missing.Value" and it worked.

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