Insert object in MS Project 2002

D

dotnet-force

Hi,

I'm writing a C# Add-In for MS Project 2002.

With the GUI of MS Project, I'm able to add objects in the current
project (such as MS Document object, Text File, as so on ...).

I want to know if there is a way to do that with the API of MS Project SDK.

I want to insert a text document in the current project to add some new
information in it and then to be able to get back that document to
retrieve the information stored int it.

An other point is that I want to control position where this document is
added.

Thank for your help.

Pascal Lenormand
ILOG
 
W

Wei-Dong Xu [MSFT]

Hi Pascal,

Thanks for posting in the community!

Currentlly we are performing some research on this issue, and we will reply
you as soon as possible if we get any results!

Have a nice day!

Wei-Dong Xu
Microsoft Product Support Services
Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 
W

Wei-Dong Xu [MSFT]

Hi Pascal,

Sorry for my dealy on this issue.

From my understanding on this issue, you are going to insert one document
into the project programmatically.

The ObjectInsert and ObjectLinks method of Project will pop up one window
for corresponding operations and you will need to interact with the windows
to insert document object or the link. From my understanding to your
scenario, since there is a programmatic way for us to insert the document
into the project, I'd suggest you can create one text file in one specifed
folder or in the same path with the project file. Then you can operate the
file to store some special information according to your scenario and then
open the file for some usages. This file is just like the old configuration
ini file in the Windows 3.0/3.1 age. This way, you can simply use the
Scripting.FileSystemObject to operate the text file. The reference for the
FileSystemObject is located at the link:
Programming the FileSystemObject
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/ht
ml/sgProgrammingFileSystemObject.asp

Please feel free to let me know if you have any further questions. I look
forward to your update.

Thank you for posting in the community!

Wei-Dong Xu
Microsoft Product Support Services
Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 
D

dotnet-force

Hi,

Thanks for your detailed answer.
I will have a look to the solution you give and if I have some troubles,
I'll post again.

Thanks.
Pascal Lenormand
ILOG
 
W

Wei-Dong Xu [MSFT]

Hi Pascal,

My pleasure to be some of service!

Thank you for posting in the community!

Wei-Dong Xu
Microsoft Product Support Services
Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 
D

dotnet-force

Hi again,

You suggest me to use a external file to store my data. It's the
solution I'm using currently. But the drawback is that when I want to
send the MS Project file to someone else, I have to send the
configuration file. So it's why I want to insert an object in the
Project file.

So I want exactly what the ObjectInsert functions does but without
displaying the dialog box. Is there a way to give the path of the file
to insert to the ObjectInsert function ?

If there is a solution, I want to control the position / size of the
icon which is displayed in the Gantt Chart view.

And all this stuff has to be done in C# and not in JScript because I'm
in the BeforeSave event of the application.

Thanks for your advices.

Pascal Lenormand
ILOG
 
W

Wei-Dong Xu [MSFT]

Hi Pascal,

Thank you for replying!

The ObjectInsert functions will pop up one window for the user interaction with it. So far as I know, there is no one method for us to insert one
document into the project file programmatically. For my workaround, I'd suggest you can place the file with the project file in the same folder and
then at runtime, you can retrieve the local path with the help of FileSystemObject.

You can reference the scripting runtime from the file: %windir%\system32\scrrun.dll. And then, use the codes below to read the configuration file.
//Code begin ---------------------------------------------------------
using Scripting;
...
Scripting.FileSystemObject oFSO = new Scripting.FileSystemObjectClass();
Scripting.FileClass oFile = (Scripting.FileClass)oFSO.GetFile(@".\test.txt");
//Code end ---------------------------------------------------------

Please feel free to let me know if you have any further questions.

Have a nice day!

Wei-Dong Xu
Microsoft Product Support Services
Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 
D

dotnet-force

Hi,

Thanks for your answer.
My problem is not to retrieve and load the file. I'm in a C# function
and I have all FileStream methods to get it and the full path of this
file is in a CustomDocumentProperties.

I just want to insert this file content in the current project as I can
do with the menu 'Insert -> Object...' and the 'Create from file'
option. But I want to do that without a user interaction in the GUI, I
just want to use the MS Project SDK Api.

But you already tell that the Application.ObjectInsert always display
the dialog box, so it seems that it's impossible to do what I want.
Correct me if I'm wrong.

Thanks for your usefull help.

Pascal Lenormand
ILOG
 
W

Wei-Dong Xu [MSFT]

Hello Pascal,

I confirm this for you. I do understand your scenario. From Project Object, if you are going to insert one object into the project file, you will have to
finish that manully. There is no one Project SDK api way to do so. This is the reason I gave you my suggestion on the configuration file.

Best regards,

Wei-Dong Xu
Microsoft Product Support Services
Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 

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