Intercept FileOpen at application level in Project 2003

J

Jane

Hello,

I would like to find out how to intercept the File > Open command to open a
text file and process it in a particular way. When a file with a known name
is opened, I want to read its contents (a list of MPP files) and run a
particular macro on each of them. If the text file is not the one I am
looking for, I want Project to process it as normal.

I know how to intercept the Project_Open routine and do my own things on a
project file but so far I haven’t been able to work out how to intercept
anything earlier than that at the application level. I’m a VC++ user and
only know VBA through writing Excel macros, so my experience is limited.

Thank you,
Jane Kirby
 
A

Abhijit

Jane,

Which VC++ project are you using? is it ATL.
Are you aware of SINK to handle notification? In your C++ App have you
derived a class from "_IDTExtensibility2".

Reply and I will guide through how

Abhijit Deshpande
 
J

Jane

Hello Abhijit,

I’m currently using Microsoft DevEnv 2003 with .Net 1.1 (but I have just
downloaded Visual Studio 2005 with .Net 2.0 although I’m not using it yet).

Originally, from within my C++ program, I wanted to run MS Project and open
a schedule file. I included all the classes from the Microsoft Project type
library into my C++ project. I used the class CMSProject for a MS Project
file. When I “#include CMSProject.h†it does not compile because there is no
definition of class Application. It is not in any of the files belonging to
the classes that I have imported from the Microsoft Project type library.

So I gave up that approach and decided to do the work of opening a set of
schedule files in MS Project (my request last week). In answer to your
question, I have not used SINK or the class IDTExtensibility2.

Do you have a code sample showing how to open a schedule file from VC++?
That is ideally what I am looking for.

Thank you,
Jane
 
A

Abhijit

Hi Jane,

Have three options for you (I know its bad to have choices when need is
desparete)

1. If you are extremely comfortable with C++, (either VC2003 or VC2005), I
will send you a sample code for that.

2. If you are not comfortable with C++ or would prefer VB, then I can send
you both.

Only small issue is, I am travelling on Apr 10th and 11th and my not have
NET access. If I get connection in between, will send you before 12th

Abhijit
 
J

Jane

Hi Abhijit,

Option 1 please (VC++). I only investigated VBA because every other message
I've seen seems to rubbish VC++ access to MS Project.
Hope to hear in the next few days,
Jane
 
A

Abhijit

Hi Jane,

Very sorry not keeping the commitment. Had a small accident, during my last
week travel. I am not able to travel to office hence unable to send you the
code snippet.

But I will give you enough pointers so that you can manage on your own.

The mechanism to solve your problem is as follows:

1. Customize MSOffice file open dialog box.
MS Offie allows you to customize the same using the "FileDialog" object. See
the details on
http://msdn2.microsoft.com/en-us/library/aa219843(office.11).aspx
You can add your own filters using " FileDialogFilters" Object (bottom of
above URL)

2. Create your own File Open Button (or replace the existing one on standard
bar) and launch the customized file dialog

3. When user confirm the dialog, you can take your own action or invoke
"Application.FileOpen" with the necessary parameters.

It may be another month or so before I can walk but if you have any
questions, I can help you out.

Regards
Abhijit
 
J

Jane

Sorry to not have replied sooner, especially since you made the effort in
spite of your injury.

I had a bit of trouble with the code sample off the Microsoft web site. The
MS Project Application object does not support the FileDialog property/method
so I am unable to override File Open. Do you know of any other code samples
on the web that do a similar thing?

Jane
PS Hope your legs are a bit better today
 
J

Jane

Hi Abhijit,

I'm still interested in your C++ code sample when you get back into the
office. In the meantime, I found a workaround.

In my Project_Open overload, I recognize a particular project name and when
it is opened, I call a new routine that opens all the project files in the
same directory one by one and runs a macro that generates metrics.

It may not be the most elegant solution, but it’s better than want I was
doing before i.e. running a batch file that opens every file.

Thanks, hope your health is improving,
Jane
 

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