Results 1 to 7 of 7
  1. #1
    Silver Lounger
    Join Date
    Jul 2001
    Location
    Ottawa, Ontario, Canada
    Posts
    1,609
    Thanks
    0
    Thanked 1 Time in 1 Post

    Add-In Confusion (VBA/Word/2003)

    Hello again Loungers

    I have two templates in my Word STARTUP folder (_1_Macros.dot and Z9_Launching.dot).The Following code is intended to individually uninstall both of the add-ins.
    <pre>Option Explicit
    Sub AutoOpen()
    Const Macro = "_1_Macros.dot"
    Const Launch = "Z9_Launching.dot"
    Const LogPath = "C:WkGpReg"
    Const Log = "UMT.log"

    Dim DirResults As String
    Dim DirResuts As String
    Dim MP As String ' Master Path the location of the User's Master
    Dim AI As AddIn
    Dim SU As String ' Location of the Word Startup folder
    Dim UN As String ' User Name

    Dim i As Long

    MP = ThisDocument.Path & Application.PathSeparator & "Macros" _
    & Application.PathSeparator
    SU = Application.StartupPath & Application.PathSeparator
    UN = Application.UserName

    ' Uninstall the Macro Suite
    For Each AI In AddIns
    If AI.Name = Macro _
    Or AI.Name = Launch Then
    AI.Installed = False
    DoEvents
    End If
    Next
    </pre>


    The only consistncy seems to be failure. At times, the fist pass through the "Uninstall the Macro Suite" snippet uninstalls both templates and deletes the Z9_Launching.dot file from the STARTUP folder. On the second pass the code fails on the AI.Installed = False command. Occasionally it fails on the first pass claiming that the add-in doesn't exist.

    Any guidance will be greatly appreciated.

    T.I.A.
    Regards
    Don

  2. #2
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Add-In Confusion (VBA/Word/2003)

    Setting .Installed to false should not cause an error, whether the add-in currently is "installed" or not.

    Is your code intentionally deleting that .DOT file? Word seems to cling to add-ins in the startup folder with special tenacity. It may well be that you can't cleanly delete the template until Word is closed.

  3. #3
    Silver Lounger
    Join Date
    Jul 2001
    Location
    Ottawa, Ontario, Canada
    Posts
    1,609
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Add-In Confusion (VBA/Word/2003)

    Hi Jefferson
    Thanks for the input.
    The code I provided is not intentionally deleting any files. The intent is to uninstall, making it possible to delete in a later snippet of code.
    If I had given you (or myself) the whole story, I'd have asked a different question.
    The template _1_Macros.dot has an AutoExit procedure which has the ability to uninstall and delete the Z9_Launching.dot template. The question now is; How does one uninstall an add-in without firing any auto macros?
    Regards
    Don

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Add-In Confusion (VBA/Word/2003)

    Does

    WordBasic.DisableAutoMacros 1

    help?

  5. #5
    Silver Lounger
    Join Date
    Jul 2001
    Location
    Ottawa, Ontario, Canada
    Posts
    1,609
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Add-In Confusion (VBA/Word/2003)

    Good day Hans

    Good old WordBasic! It most certainly does help. Am I correct in assuming that

    WordBasic.DisableAutoMacros 0

    will be required later?
    Regards
    Don

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Add-In Confusion (VBA/Word/2003)

    If you want to enable auto-macros in the same session, yes.

  7. #7
    Silver Lounger
    Join Date
    Jul 2001
    Location
    Ottawa, Ontario, Canada
    Posts
    1,609
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Add-In Confusion (VBA/Word/2003)

    Thank you again Hans

    I was about to write some unnecessarily complicated code because of <post#=385,180>post 385,180</post#> .
    Regards
    Don

Posting Permissions

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