Results 1 to 12 of 12
  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 problems (VBA/Word/2003 SP2)

    The following code runs well for a while then it doesn't for some reason. <pre>Public Sub ReplaceTemplate(Optional Abort As Boolean)


    Dim myaddin As AddIn
    Dim myfile As Document

    For Each myaddin In AddIns
    With myaddin
    If .Name = MacroName Then
    If .Installed Then
    On Error Resume Next
    AddIns(MacroName).Installed = False
    On Error GoTo 0
    End If
    Exit For
    End If
    End With
    Next
    </pre>



    <UL><LI>The failure appears at the AddIns(MacroName).Installed = False command. with Runtime error 424 (see graphic).
    <LI>Although there is a failure; the add-in has been changed from True to False.
    <LI>The On Error command is of no value, apparently as the failure is not detected in my code, but the Word code (see graphic of stack)
    <LI>The module is set to Option Explicit
    <LI>The project compiles without error[/list]Any ideas will be most welcome.

    T.I.A.
    Regards
    Don

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

    Re: Add-In problems (VBA/Word/2003 SP2)

    What happens if you change
    <code>
    AddIns(MacroName).Installed = False
    </code>
    to
    <code>
    .Installed = False</code>

  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 problems (VBA/Word/2003 SP2)

    Same problem. That was my original code; I revised it hoping against hope. . .
    Regards
    Don

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

    Re: Add-In problems (VBA/Word/2003 SP2)

    How about replacing the entire loop with

    On Error Resume Next
    Addins(MacroName).Installed = False
    ' Optional: check for error
    If Err Then
    MsgBox "Something went wrong...", vbInformation
    End If

  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 problems (VBA/Word/2003 SP2)

    Hans
    Perhaps I should have told you the complete story first--Apologies.
    <UL><LI>The purpose of the previously provided snippet is to allow replacement of the template with a later version of the same name.
    <LI>What object could be missing when I receive error code 424? Most probably, the template that we are trying to disconnect.
    <LI>If Word & Co. believe the file to be missing, perhaps I can replace it.
    <LI>Hence, the following code, which seems to work.
    <LI>Any observations?[/list]<pre>Public Sub ReplaceTemplate(Optional Abort As Boolean)


    Dim myaddin As AddIn
    Dim myfile As Document

    WordBasic.DisableAutomacros 1
    Documents.Open FileName:=SourceFolderMacros & MacroName, ConfirmConversions:=False, _
    ReadOnly:=False, AddToRecentFiles:=False, PasswordDocument:="", _
    PasswordTemplate:=pwd, Revert:=False, WritePasswordDocument:="", _
    WritePasswordTemplate:=pwd, Format:=wdOpenFormatAuto

    On Error Resume Next
    SaveResume:
    Documents(MacroName).SaveAs FileName:=TargetFolder & "" & MacroName, FileFormat:= _
    wdFormatTemplate, LockComments:=False, Password:="", _
    AddToRecentFiles:=True, WritePassword:="", ReadOnlyRecommended:=False, _
    EmbedTrueTypeFonts:=False, SaveNativePictureFormat:=False, SaveFormsData _
    :=False, SaveAsAOCELetter:=False
    If Err Then
    On Error GoTo 0
    AddIns(MacroName).Installed = False
    GoTo SaveResume
    End If
    On Error GoTo 0
    DoEvents

    AddIns(MacroName).Installed = True

    Documents(MacroName).Close
    WordBasic.DisableAutomacros 0
    End Sub
    </pre>


    Thanks for your patience and support.
    Regards
    Don

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

    Re: Add-In problems (VBA/Word/2003 SP2)

    I don't think I can say anything sensible about this, sorry. Perhaps someone else can...

  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 problems (VBA/Word/2003 SP2)

    Thanks again
    Regards
    Don

  8. #8
    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 problems (VBA/Word/2003 SP2)

    Presumably changing .Installed to false does more than flip a property value. It actually unloads the add-in? Could that add-in be in use?

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

    Re: Add-In problems (VBA/Word/2003 SP2)

    I don't think so Jefferson.

    The operating code is run from AutoExec.main found in the template named Z_Launching.dot . This should be the first Auto code to run after any Auto code found in Normal.dot

    The add-in being uninstalled is named _1_Macros.dot and as such should be the last project to have any auto code fired.

    Thanks for the interest
    Regards
    Don

  10. #10
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Add-In problems (VBA/Word/2003 SP2)

    > allow replacement of the template with a later version of the same name.
    Hi Don.
    Did you look through the code in my Setup.dot?
    It does what I believe you are trying to do, upgrades versions of addins, even when they are "live".
    Setup.dot comes with every d/l from my web site. You could d/l any package and then inspect the source code in the Setu.dot.

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

    Re: Add-In problems (VBA/Word/2003 SP2)

    Thanks Chris
    I will review that right now.
    Regards
    Don

  12. #12
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Add-In problems (VBA/Word/2003 SP2)

    Look for the line ' CG:2048 frmPaths.Show in module Utilities and remove the comment. That will give you a choice of installation folder.
    If you want to see SetUp in action, d/l the latest "Proje" (grin!)

Posting Permissions

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