Bypass Save Dialog using Interop?

M

Martin Rais

Hi. I am using Com Interop to open a MS Project project in my application
and then Show the MS Project app. Then I capture the event when the app
closes and reload the mpp file in my app. The problem is that when I make a
change in the project I am editing with MS Project, a dialog opens and asks
me if I would like to save the changes in the file I am opening. Is there
any way to skip this dialog ? Is there any way to skip it and also use a
dialog of my own?
Thanks in advance!
Martin
 
M

Martin Rais

But I am not the one who saves the file. Ms Project does. The only thing I
do is open a Ms Project file using COM Interop and then show the Ms Project
app to the user. Then I capture the ApplicationBeforeClose event to know
that it has closed the file and start my processing.
Any suggestion?
 
R

Rod Gill

Your first post says "save the changes in the file I am opening". How can
you save changes when opening a file?

MSProject does not initiate closing the file, a user or you do. If your code
closes the file, use my solution. If the user does ask them to choose save
or not.

Otherwise, I don't understand what's happening in your example, can you
explain further please?

--

Rod Gill
Project MVP

Project VBA Book, for details visit:
http://www.projectvbabook.com

NEW!! Web based VBA training course delivered by me. For details visit:
http://projectservertraining.com/learning/index.aspx
 
M

Martin Rais

It's easy. I have an mpp file. In C# I use COM Interop to open the file with
Ms Project (use the OpenFile method). Then, I show the instance of Ms
Project (Visible = true).
Then the user, not me, will do whatever he wants with that file. Supposing
the user has modified the project file, when he closes the Ms Project app
(pressing the X button on the top right corner), Ms Project will ask if he
wants to save changes to the file. Problem is that I don't want Ms Project
to ask this. I want myself to control that. Why? Because what I do is create
a temporary Ms Project file with a name such as "tmp.mpp". When Ms Project
asks to save changes to the file, it will say "Do you want to save changes
to tmp.mpp?". Well, I don't want the user to know that there is a tmp.mpp
file!! I want it to be transparent for him. I have in mind two possible
solutions: One is to not show that dialog and show one of my own that would
say "Do you want to save changes?". And second, to always save without
asking.
Problem is that I don't know how to tell Ms Project not to show that dialog.
Any ideas???
Thank you very much for answering!

Martin
 
R

Rod Gill

That's an internal message you have no control of. The only option is to
save the project before the message gets triggered of force a close with no
save. I think you will just need to experiment as I do not know how events
will be effected by catching them in C#.

--

Rod Gill
Project MVP

Project VBA Book, for details visit:
http://www.projectvbabook.com

NEW!! Web based VBA training course delivered by me. For details visit:
http://projectservertraining.com/learning/index.aspx
 

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