Results 1 to 5 of 5
  1. #1
    New Lounger
    Join Date
    Aug 2004
    Location
    Brisbane, Queensland, Australia
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Macro execution on file Open (2K)

    I have a macro which I would like to run each time I open a particular project file.
    Can someone provide some sample code to achieve that?
    Steve

  2. #2
    Silver Lounger GARYPSWANSON's Avatar
    Join Date
    Aug 2001
    Location
    Frederick, Maryland, USA
    Posts
    1,788
    Thanks
    0
    Thanked 2 Times in 2 Posts

    Re: Macro execution on file Open (2K)

    You will need to insert some code for the current project. To do this, open your project and then press ALT and F11 at the same time to lauch VB. The project viewer window will show current projects. Right click on your current project and select view code to open a window to input code. If you don't see the selection for view code, expand the node and click on the "this project" that is the current project.

    In the code window, input the following:


    Sub Project_Open(ByVal pj As Project)
    MsgBox "Hooray"

    End Sub

    Each time you open your project, the Message Box Hooray should appear. You should be able to launch your macro from here.

    HTH
    Regards,

    Gary
    (It's been a while!)

  3. #3
    Silver Lounger GARYPSWANSON's Avatar
    Join Date
    Aug 2001
    Location
    Frederick, Maryland, USA
    Posts
    1,788
    Thanks
    0
    Thanked 2 Times in 2 Posts

    Re: Macro execution on file Open (2K)

    ... One last item.

    To launch your macro, input the following in place of MsgBox "Hooray" in the last post.


    MSProject.Application.Macro "YourMacroName"


    Your code should look like this:

    Sub Project_Open(ByVal pj As Project)
    MSProject.Application.Macro "YourMacroName"
    End Sub
    Regards,

    Gary
    (It's been a while!)

  4. #4
    New Lounger
    Join Date
    Aug 2004
    Location
    Brisbane, Queensland, Australia
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Macro execution on file Open (2K)

    Works beautifully. Thanks Gary.
    Can you recommend a reference source where I could find this stuff documented - apart from Woody's of course?
    Steve

  5. #5
    Silver Lounger GARYPSWANSON's Avatar
    Join Date
    Aug 2001
    Location
    Frederick, Maryland, USA
    Posts
    1,788
    Thanks
    0
    Thanked 2 Times in 2 Posts

    Re: Macro execution on file Open (2K)

    Steve,

    I pretty much use the Special Edition Using Project 2000 by Tim Pyron and published by Que. I find it most helpful especially with sample code and example on a CD in the back of the book. However, I am sure there are other good references as well.

    HTH
    Regards,

    Gary
    (It's been a while!)

Posting Permissions

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