Com-AddIn OrganizerMoveItems

Z

Zack Halbrecht

Hi,

I'm writing a COM-AddIn for Microsoft Project 2003 that will copy
various Filters to the user's Global.MPT file using OrganizerMoveItem.

This code works if Use it in a VBA Macro, but I cannot for the life of
me get it to work in this COM-AddIn in C#.

I know that the AddIn itself is registering and connecting properly and
I am getting to this point OK:

public void OnStartupComplete(ref System.Array custom)

{

object oMissing = System.Reflection.Missing.Value;
try

{

applicationObject.OrganizerMoveItem(MSProject.PjOrganizer.pjFilters,
"C:\\Filters.mpp" , "Global.MPT", oMissing, oMissing);
System.Windows.Forms.MessageBox.Show("Good To Go");

}


catch (Exception ex)

{

System.Windows.Forms.MessageBox.Show(ex.ToString());

}

}


I get a NullReference Exception on the OrganizerMoveItem line. I think
that the problem is with the second parameter FileName. I have tried
"C:\\Filters.mpp", applicationObject.ActiveProject.Name, "Filters.mpp"
(with Filters.mpp being passed to WINPROJ.exe On the start of debugging
- all with the same result.

If anyone could help me nip this thing I would be very very grateful.
Thanks in advance!
 
R

Rod Gill

Hi,

Record the copy to Global in VBA then look at the file name used in the
recorded code. Try the same description in your code.

Try "C:\ instead of C:\\ as well.

--
For VBA posts, please use the public.project.developer group.
For any version of Project use public.project
For any version of Project Server use public. project.server

Rod Gill
Project MVP
For Microsoft Project companion projects, best practices and Project VBA
development services
visit www.project-systems.co.nz/
Email rodg AT project-systems DOT co DOT nz
 
Z

zack

Hi Rod,

Thanks for the advice, but

"C:\" will not compile in C#

The backslash needs to be escaped by another backslash to be a vaild
string.

Any other ideas?

Thanks,
 
R

Rod Gill

Did you record in Project VBA and copy the command and adjust for C#?

--
For VBA posts, please use the public.project.developer group.
For any version of Project use public.project
For any version of Project Server use public. project.server

Rod Gill
Project MVP
For Microsoft Project companion projects, best practices and Project VBA
development services
visit www.project-systems.co.nz/
Email rodg AT project-systems DOT co DOT nz
 

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