Connect to Project Server 2003 in VB.Net

S

Scott

Hi,
I have code in vb.net that saves project server files to a file server. It
was working fine, untill I introduced some code to create a new folder. Now
my application object has lost it's connection to the server. It thinks it's
working offline.

As soon as I start working with the filesystemobject, project server goes
offline.

Is there a way to tell my application object to use the server to open files?

Here's a snippet of my code.

___________________________________________________________________

Dim pApp As Microsoft.Office.Interop.MSProject.Application
Dim fso As Scripting.FileSystemObject, fldr As Scripting.Folder, fileName As
String
Dim folderName As String, reportingDate As Date

fso = CreateObject("Scripting.FileSystemObject")
reportingDate = Now
folderName = "\\Project Management\older_versions\" & reportingDate.Month &
"_" & reportingDate.Day & "_" & reportingDate.Year

If Not fso.FolderExists(folderName) Then
fldr = fso.CreateFolder(folderName)
Else
folderName = Trim(folderName) & "_" & reportingDate.Hour & "_" &
reportingDate.Minute
fldr = fso.CreateFolder(folderName)
End If

fileName = fldr.Path & "\test.mpp"

pApp = CreateObject("msproject.application")
pApp.Visible = True

pApp.FileOpen(Name:="<>\test.Published")
If fso.FileExists("\\Pegasus\AllAccess\Project Management\test.mpp") Then
fso.DeleteFile("\\Pegasus\AllAccess\Project Management\test.mpp", True)
End If
pApp.FileSaveAs(Name:="\\Pegasus\AllAccess\Project Management\test.mpp",
FormatID:="MSProject.MPP")
pApp.FileClose()
 
B

Boaz Lev [MSFT]

Hi Scott,

I am not too sure what is going on with your code, but I think part of the
problem is that you are mixing COM and .NET. Supposedly, it should all work
fine, but it is really the only thing I can put my finger on (and there are
always these fine little details that cause the big problems). I am curious
why you are not using purely .NET constructs. You can use the
Directory.Exists method to match up with fso.FolderExists,
Directory.CreateDirectory to match fso.CreateFolder. fso.FileExists is
matched by File.Exists. That way you will at least know that it is not some
interop issue that is causing the problems.

Thanks,
 

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