none
Write macro into MS Project 2013 by OLE Automation RRS feed

  • Question

  • Hello,

    I need create macro in MSP 2013 and then run it. Is there any way how import macro into global.mpt or in actually opened project by OLE Automation?

    Monday, May 6, 2013 11:28 AM

Answers

  • With OrganizerMoveItem first delete the module from the GLobal then move it. Will always update the Global code. Use DisplayAlerts to hide are you sure messages.

    For security messages you either need to set macro security to Low or add a security certificate.

    activeproject.VBProject.VBComponents.Import Filename


    Rod Gill

    The one and only Project VBA Book

    Rod Gill Project Management

    • Marked as answer by Dan.Fo Thursday, May 9, 2013 8:30 AM
    Tuesday, May 7, 2013 8:42 PM
    Moderator

All replies

  • Yes. Use Organizer to copy to Global. You can control just about everything in Project from other OLE applications and Project can control just about everything in other OLE applications. Plenty of samples on MSDN and the net or indeed, my book.

    If you have a more specific problem, let us know.


    Rod Gill

    The one and only Project VBA Book

    Rod Gill Project Management

    • Marked as answer by Dan.Fo Tuesday, May 7, 2013 8:15 AM
    • Unmarked as answer by Dan.Fo Tuesday, May 7, 2013 11:15 AM
    Monday, May 6, 2013 8:12 PM
    Moderator
  • Thank you, it helped. I used OrganizerMoveItem procedure for coping data module from mpp file to global.mpt. I still have some problems with it:

    1) I need to copy this data module only if not exists in global.mpt. How can i identify if module exists in global.mpt?

    2) When I open file with macro, Dialog 'There can be problem with security. Macros are disabled. Do you want enable macros?'. How can i supress this message? Property DisplayAlerts=False does not help.

    3) Not nessessary, but IMHO it would be interesting to import module not from xxx.mpp file, but from text (exported visual basic) file xxx.bas. Is there posibility like this?

    Tuesday, May 7, 2013 11:40 AM
  • With OrganizerMoveItem first delete the module from the GLobal then move it. Will always update the Global code. Use DisplayAlerts to hide are you sure messages.

    For security messages you either need to set macro security to Low or add a security certificate.

    activeproject.VBProject.VBComponents.Import Filename


    Rod Gill

    The one and only Project VBA Book

    Rod Gill Project Management

    • Marked as answer by Dan.Fo Thursday, May 9, 2013 8:30 AM
    Tuesday, May 7, 2013 8:42 PM
    Moderator