PDA

View Full Version : Opening an Enterprise Template with VBA



NathanWright
07-02-2010, 06:30 AM
Greetings all,

I am attempting to create a project from an Excel file. My plan is to...

Open MSP
Open a particular enterprise template
Fill in the work/cost/resources from the spreadsheet
Adjust some enterprise custom fields
Leave the project open for the user to review/save/publish/close.So I'm stuck on step 2. Here is my code...



Private Sub MyButton_Click()
Dim returnValue As Variant
Dim appProject As MSProject.Application
Dim prjMyProject As MSProject.Project
Dim bResponse As Boolean

'Open MSP with shell so that we connect to server
returnValue = Shell("C:\Program Files\Microsoft Office\Office12\WINPROJ.EXE /s <server url>", vbNormalFocus)

'Create reference to MSP app just created
Set appProject = New MSProject.Application

'Open a template of appropriate size
bResponse = appProject.FileNew(Template:="aEnterpriseTemplate.mpt")

'Future code...

Exit Sub


So I tried recording a macro while I manually opened an etnerprise template using 'File -> New -> On computer -> Tab:Enterprise Templates -> Make Selection -> OK.' It wasn't very helpful...



Sub Macro1()
' Macro Macro1
' Macro Recorded Fri 7/2/10 by ADB-ZAV\nwright.
FileNew Template:="", FileNewWorkpane:=True
FileOpenEx Name:="<>\", ReadOnly:=False, FormatID:="MSProject.PSI.12"
End Sub


Do I need to create a file share on the project server to the template repository and directly access them? Any assistance would be appreciated.

Thanks,
Nathan

NathanWright
07-02-2010, 12:12 PM
Ok I figured it.



appProject.FileOpenEx Name:="<>\aEnterpriseTemplateName", ReadOnly:=False


:doh: