Creating Project file in MSP98 from Access 2k

P

Phred Bear

Can somebody point me in the right direction? I'm trying to create a
project, in MSP 98, from Access 2k and I am having difficulty with the
documentation, or lack of. I've looked at everything I can find on the web
but much of it is conflicting.

Here is my code, with which I have tried several variations on the syntax,
but it keeps throwing an error "Object doesn't support this property or
method"

If someone can give me the first few lines which work to start me off, I can
figure it out from there.




Sub CreateNewProjectFile()
On Error GoTo Err_CreateNewProjectFile

Dim pj As Object
Dim PathStr, fName As String
Dim fs As Variant

PathStr = getpath(CurrentDb.Name)
fName = PathStr & "Investigation.mpp"

'Delete file if it already exists
Set fs = CreateObject("Scripting.FileSystemObject")
If fs.FileExists(fName) Then
Kill fName
End If


Set pj = CreateObject("MSProject.Project")
pj.FileNew (False)


pj.Visible = True


'Do some stuff then close file in "Project"

ExitHere:
On Error Resume Next
' Clean up
Set pj = Nothing
Exit Sub

On Error Resume Next
Exit_CreateNewProjectFile:
Exit Sub

Err_CreateNewProjectFile
MsgBox Err.Description

pj.FileSaveAs (fName)

End Sub


Thanks,

Ian Millward
Edinburgh
 
J

John Nurick

Hi Ian,
Try setting a reference to the MS Project 98 library, whatever it's called.
Then define all your Project objects as such, e.g.
Dim pj As MsProject.Project

This means that Intellisense, the Object Browser and the compiler can help
you get the syntax right. Once the code's running properly you can switch
back to late binding.

Also, if your code is failing, comment out the On Error Goto Label, set a
breakpoint and step through the code so you can at least know which line is
triggering the error.
 

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