Consulting

Results 1 to 2 of 2

Thread: Opening an Enterprise Template with VBA

  1. #1

    Opening an Enterprise Template with VBA

    Greetings all,

    I am attempting to create a project from an Excel file. My plan is to...
    1. Open MSP
    2. Open a particular enterprise template
    3. Fill in the work/cost/resources from the spreadsheet
    4. Adjust some enterprise custom fields
    5. 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

  2. #2
    Ok I figured it.

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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •