Consulting

Results 1 to 4 of 4

Thread: Removing a macro Template

  1. #1
    VBAX Regular
    Joined
    Oct 2005
    Posts
    15
    Location

    Removing a macro Template

    I currently have a autoOpen macro that is fired from VB.net and I really only need this macro to be run once IE not when the document is opened at a later date. I would normally stick the code in a differant macro procedure and just run it once but the problem is that I can only fire the Auto marcros form VB.net.

    Basically I need some VBA code that will either allow the macro to only run once, or remove the template containing the macro from the document after it has been run. I think I can do something of this sort with ActiveDocument.VBProject.VBComponents.Remove but I just cant quite seem to get it right, help n e 1...........

  2. #2
    Moderator VBAX Master geekgirlau's Avatar
    Joined
    Aug 2004
    Location
    Melbourne, Australia
    Posts
    1,464
    Location
    This issue came up recently, and a couple of different approaches were discussed: check out http://www.vbaexpress.com/forum/showthread.php?t=5663

  3. #3
    VBAX Regular
    Joined
    Oct 2005
    Posts
    15
    Location
    Hmm these are both interesting ideas, One of which doesnt appear to be applicable to word from what I can tell (IE renaming the file or workbook.name in this case) as name is a readonly property and names.add doesnt appear to be valid in VBA word.

    As for having a file that persists this information that is a nice idea , but the problem is that I need to be able to attach the document to a email after generation to allow some else to view it with out the macro running, and porting it with another file means I need to send that file which is obviously a danger incase the person doesnt save it in the same place...

    How about making about adding a word to the end of the document that is white (IE invisible) that holds the macro run status? anybody got any ideas on how to do this?

  4. #4
    VBAX Regular
    Joined
    Oct 2005
    Posts
    15
    Location
    Actually ive found of doing it, just use activeDocument.attachTemplate = ""

    This means it is only ever run once........how easy was that? thanks anyways, there was some good stuff there that got me thinking on solutions for other problems in other languages.

    Cheers again

Posting Permissions

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