Development help

G

GT

Can someone help me... If I am in the wrong group, please direct me to a
more appropriate one. Even point me to a help system online would be fine...

I am trying to write some software that links into MS Project and collects
resource information through the API. I am using Microsoft Visual Studio,
C++ 6. I have an MSProject Application and I want to call the FileOpen()
method. There are 15 parameters in the method, but I don't know what values
the method is expecting for those parameters. The only help I can find is in
the VB Object Browser within MS Project and it just repeats the parameter
list with no indication of what values are expected.

I just want to open a file remotely. I have the filename and there are no
passwords or anything complex in the file!

The header for the method is all I have to go on...

BOOL MSProj_MSProject::FileOpen(const VARIANT& Name, const VARIANT&
ReadOnly, const VARIANT& Merge, const VARIANT& TaskInformation, const
VARIANT& Table, const VARIANT& Sheet, const VARIANT& NoAuto, const VARIANT&
UserID, const VARIANT& DatabasePassWord, const VARIANT& FormatID, const
VARIANT& Map, long openPool, const VARIANT& Password, const VARIANT&
WriteResPassword, const VARIANT& IgnoreReadOnlyRecommended)




x-- 100 Proof News - http://www.100ProofNews.com
x-- 3,500+ Binary NewsGroups, and over 100,000 other groups
x-- Access to over 1.6 Terabytes per Day - $8.95/Month
x-- UNLIMITED DOWNLOAD
 
S

Steve Kearon

Theoretically, your question would be more appropriate for the
microsoft.public.project.developer newsgroup, but you won't find many VC++
answers.

The main (or perhaps ONLY) reference for automation of MSProject is the
online help - goto reference, then visual basic for applications, then
choose "view the project2003 object model". Everything is described in terms
of VBA.

For your specific query, here's a simple cut+paste from something I did:

BOOL CAutoProjectApp::FileOpen(LPCTSTR szFileName, BOOL bReadOnly, BOOL
bAutoOpen, BOOL bMerge)
{
BOOL bOK = TRUE;
COleVariant FileName(szFileName);
COleVariant ReadOnly((short)bReadOnly,VT_BOOL);
COleVariant NoAuto((short)!bAutoOpen,VT_BOOL); // note: param T to AVOID
running Auto_Open macros!
COleVariant Merge((short)bMerge,VT_BOOL);

VARIANT Null; // TaskInformation, Table and Sheet
VariantInit(&Null);
Null.vt = VT_NULL;

static BYTE BASED_CODE parms[] =
VTS_VARIANT VTS_VARIANT VTS_VARIANT VTS_VARIANT VTS_VARIANT VTS_VARIANT
VTS_VARIANT;
TRY {
InvokeHelper(0x66, DISPATCH_METHOD, VT_EMPTY, NULL, parms,
&FileName, &ReadOnly, &Merge, &Null, &Null, &Null, &NoAuto);
}
CATCH (CException, e)
{
TRACE("Failed to open project\n");
bOK = FALSE;
}
END_CATCH
return bOK;
}

This assumes that CAutoProjectApp is derived from COleDispatchInterface.

Hope this helps
Steve
 
G

GT

Thanks for the help Steve.

That has at least told me which parameters I can ignore and which to
provide. Might be getting somewhere now!




x-- 100 Proof News - http://www.100ProofNews.com
x-- 3,500+ Binary NewsGroups, and over 100,000 other groups
x-- Access to over 1.6 Terabytes per Day - $8.95/Month
x-- UNLIMITED DOWNLOAD
 
R

Rod Gill

Hi,

C++ is a desperately slow environment to code Office automation. VB would be
10 times quicker and take a 10th of the lines of code.

For a good idea record a macro of opening a file in project. In VB or VBA in
Word or Excel first add a reference to Project then:

Dim projApp as Project.Application

Set ProjApp=CreateObject("MSProject.Application")
ProjApp.Visible=True
ProjApp.FileOpen "MyProject.Mpp"

That is all it takes in VB plus of course some error handling and closing
the Object. I think in C you have to provide a value for every parameter, so
in VBA help simply use the default values. VB only needs to specify Required
parameters, the rest are optional which is partly why VB is much better for
Office Automation. Can you create a separate module in VB for this?
 
G

GT

Rod Gill said:
Hi,

C++ is a desperately slow environment to code Office automation. VB would
be 10 times quicker and take a 10th of the lines of code.

For a good idea record a macro of opening a file in project. In VB or VBA
in Word or Excel first add a reference to Project then:

Dim projApp as Project.Application

Set ProjApp=CreateObject("MSProject.Application")
ProjApp.Visible=True
ProjApp.FileOpen "MyProject.Mpp"

That is all it takes in VB plus of course some error handling and closing
the Object. I think in C you have to provide a value for every parameter,
so in VBA help simply use the default values. VB only needs to specify
Required parameters, the rest are optional which is partly why VB is much
better for Office Automation. Can you create a separate module in VB for
this?

That would be one solution, but the rest of our application (23 exes and
dlls) is written in MFC C++, so we don't really want to change environments.
All is fixed now. As ALL of the parameters are actually optional (not
something that is evident in the interface), I simply call the FileOpen
method and provice either just the filename or nothing. If you provide
nothing, then MS Project automatically displays the FileOpen dialog and does
all the work for you. Once the user has selected the correct file, I simply
loop round all the resources and teams and extract the necessary information
for our tool. The interface is not slow in my experience, but we are not
doing anything complex - a simple import of resource information and export
of task and team information.




x-- 100 Proof News - http://www.100ProofNews.com
x-- 3,500+ Binary NewsGroups, and over 100,000 other groups
x-- Access to over 1.6 Terabytes per Day - $8.95/Month
x-- UNLIMITED DOWNLOAD
 

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