Consulting

Results 1 to 13 of 13

Thread: Solved: Can't get my XLA auto installer to work...

  1. #1
    VBAX Contributor
    Joined
    Jun 2007
    Posts
    150
    Location

    Solved: Can't get my XLA auto installer to work...

    This is driving me nuts...

    I'm trying to set up an auto-installer for my XLA file. I'm basing it on the code listed in this article:
    vbaexpress.com/forum/showthread.php?t=10855

    Its two pieces, a data workbook as XLS and a macro workbook as XLA. I'll be distributing it as an XLS, so built into the workbook open event is a check for file extension... it is .XLS, it runs the AddInInstaller() sub.

    Here is the relevant code:
     Application.EnableEvents = False
    AddIns.Add(AddInFname).Installed = True
    Application.EnableEvents = True
    Which produces this error:
    Run-time error '1004':
    Unable to get the Add property of the AddIns class
    I've tried EVERYTHING! Using different forms of the file name, using different locations, using ThisworkBook.FullName, none of it works!
    I also tried changing the code a little, to separate the steps:
     Application.EnableEvents = False
    AddIns.Add (AddInFname)
    AddIns(AddInTitle).Installed = True
    Application.EnableEvents = True
    This produces a slightly different error:
    Run-time error '1004':
    Add method of Addins class failed
    I even tried throwing out my code and pasting in the code from the article verbatim: same error, on the same piece of code.

     AddIns.Add(ThisWorkbook.FullName, True) _ 
    .Installed = True
    Please help, I'm pulling my damn hair out.
    Last edited by Bob Phillips; 01-14-2022 at 07:30 AM. Reason: Updated code tags

  2. #2
    Administrator
    Chat VP
    VBAX Guru johnske's Avatar
    Joined
    Jul 2004
    Location
    Townsville, Australia
    Posts
    2,872
    Location
    There are two possibilities - the relevant bit of the code is...
     
    If Listed Then 
    'check this addins checkbox in the addin dialog box
    AddIns(AddinTitle).Installed = True 
    Else 
    'it's not listed (not previously installed)
    'add it to the addins collection
    'and check this addins checkbox
    AddIns.Add(ThisWorkbook.FullName, True) _ 
    .Installed = True 
    End If
    EDIT: Out of curiosity - this uses the same code, do you have the same problem when installing it?
    Last edited by Bob Phillips; 01-14-2022 at 07:31 AM. Reason: Updated code tags
    You know you're really in trouble when the light at the end of the tunnel turns out to be the headlight of a train hurtling towards you

    The major part of getting the right answer lies in asking the right question...


    Made your code more readable, use VBA tags (this automatically inserts [vba] at the start of your code, and [/vba ] at the end of your code) | Help those helping you by marking your thread solved when it is.

  3. #3
    VBAX Contributor
    Joined
    Jun 2007
    Posts
    150
    Location
    Hey, alright! A response from the man who wrote the article!

    Well, after beating my head against this for nearly 8 hours, I finally figured out the problem!!!

    Excel cannot update the AddIns collection (either through the Excel Interface OR programmatically) UNLESS there is an open, visble workbook!
    If there is no open, visible WB, it trying to add the AddIn throws the error.

    It took me a ton of error trapping to figure that out.

    My work around is this: add a dummy workbook at the begining of the install, and then close (false) near the end!

    Finally, my macro works properly!

    I'm WAY too bleary eyed to clean up all the code now, but tomorrow morning, I'll finnish all the code and post it here.

    I'm surprised no one else has had this problem... maybe I've got something wierd in my settings?

  4. #4
    Administrator
    Chat VP VBAX Guru johnske's Avatar
    Joined
    Jul 2004
    Location
    Townsville, Australia
    Posts
    2,872
    Location
    But did you have the same problem with the addin in the link I gave?
    You know you're really in trouble when the light at the end of the tunnel turns out to be the headlight of a train hurtling towards you

    The major part of getting the right answer lies in asking the right question...


    Made your code more readable, use VBA tags (this automatically inserts [vba] at the start of your code, and [/vba ] at the end of your code) | Help those helping you by marking your thread solved when it is.

  5. #5
    Moderator VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location
    The addin at your link installed ok for me John.
    Steve
    "Nearly all men can stand adversity, but if you want to test a man's character, give him power."
    -Abraham Lincoln

  6. #6
    Administrator
    Chat VP VBAX Guru johnske's Avatar
    Joined
    Jul 2004
    Location
    Townsville, Australia
    Posts
    2,872
    Location
    Quote Originally Posted by lucas
    The addin at your link installed ok for me John.
    Yes, I suspect Dr.K had modified it and that was what was causing the problem.

    Thing is with this, is that when building that code, I was in contact with a couple of other coders (other boards) that were trying to do the same thing and we were all having various problems getting it to work properly.

    Took a while but I saw that you had to be 1) methodical about it, as well as being methodical 2) the various operations all had to be done in a certain order (although there seemed no apparent reason why some couldn't be done in another order) but do them in another order and strange bugs appeared.

    That's why I ended up making it generic code i.e. just paste in any workbook as is and run the code - there's only problems if you alter it
    You know you're really in trouble when the light at the end of the tunnel turns out to be the headlight of a train hurtling towards you

    The major part of getting the right answer lies in asking the right question...


    Made your code more readable, use VBA tags (this automatically inserts [vba] at the start of your code, and [/vba ] at the end of your code) | Help those helping you by marking your thread solved when it is.

  7. #7
    VBAX Contributor
    Joined
    Jun 2007
    Posts
    150
    Location
    Ok, so i figured it all out... you are correct, one line that I changed doomed me...

    I combined the Reinstall/Install together: basically I added the lines to remove old code before installation. I wrapped them in a "On Error resume next" set of code, like I usually do when deleting files that may not be there.

    'uninstall any previous versions
    On Error Resume Next
    Workbooks(RF_AI_FName & ".xla").Close False
    AddIns(RF_AI_Title).Installed = False
    Kill (Application.UserLibraryPath & RF_AI_FName & ".xla")
    On Error GoTo 0


    The line that caused all the problems : AddIns(RF_AI_Title).Installed = False
    This line is totally unnecessary, the old AddIn is removed just fine by simply closing it and killing the file.

    For whatever reason, having that line in there made the macro crash when it tried to .installed = true for the final AddIn install... UNLESS there is an open, visible workbook. Yes its true, I doubted it myself when I got up this morning, but I tested it pretty extensively. Adding and later removing a dummy workbook makes the code run fine.

    So, I have two solutions:
    1. Delete the unnecessary code line.
    2. Add a few lines to add and remove a useless workbook.

    I went with option 1.

    Thanks for the help, guys.
    Last edited by Bob Phillips; 01-14-2022 at 07:33 AM. Reason: Updated code tags

  8. #8
    VBAX Newbie
    Joined
    Jan 2022
    Posts
    1
    Location
    Hello John,

    By any chance can you please share the full code again. The link you have pasted is not valid anymore. Thanks

  9. #9
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,724
    Location
    Unlikely, since Dr.K's last post was June 15, 2011
    ---------------------------------------------------------------------------------------------------------------------

    Paul


    Remember: Tell us WHAT you want to do, not HOW you think you want to do it

    1. Use [CODE] ....[/CODE ] Tags for readability
    [CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
    2. Upload an example
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
    3. Mark the thread as [Solved] when you have an answer
    Thread Tools (on the top right corner, above the first message)
    4. Read the Forum FAQ, especially the part about cross-posting in other forums
    http://www.vbaexpress.com/forum/faq...._new_faq_item3

  10. #10
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    There are plenty of free installers out there, I use InnoSetup.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  11. #11
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,724
    Location
    Quote Originally Posted by Bob Phillips View Post
    There are plenty of free installers out there, I use InnoSetup.
    I looked at that

    Can it install a XLAM? I didn't see any way
    ---------------------------------------------------------------------------------------------------------------------

    Paul


    Remember: Tell us WHAT you want to do, not HOW you think you want to do it

    1. Use [CODE] ....[/CODE ] Tags for readability
    [CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
    2. Upload an example
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
    3. Mark the thread as [Solved] when you have an answer
    Thread Tools (on the top right corner, above the first message)
    4. Read the Forum FAQ, especially the part about cross-posting in other forums
    http://www.vbaexpress.com/forum/faq...._new_faq_item3

  12. #12
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Yeah Paul, that is what I mainly use (used) it for.

    You need to write some script to modify the registry, which is not a bit of chore, especially as it is Delhi as I recall, which is Pascal. I haven't done this in a while, but I am sure to have an example lying around that I can show you if interested.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  13. #13
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,724
    Location
    Thanks -- I used to work in Delphi since I like(d) PASCAL for stand-alone applications, but for work reasons (before I retired) I ended up just using VBA to work within the MS Office suite


    I do have a XLSM that saves itself as a XLAM, but it can be a little cumbersome, so I'd like to look at another example


    If you don't mind searching for an example, I'll PM you my email address
    ---------------------------------------------------------------------------------------------------------------------

    Paul


    Remember: Tell us WHAT you want to do, not HOW you think you want to do it

    1. Use [CODE] ....[/CODE ] Tags for readability
    [CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
    2. Upload an example
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
    3. Mark the thread as [Solved] when you have an answer
    Thread Tools (on the top right corner, above the first message)
    4. Read the Forum FAQ, especially the part about cross-posting in other forums
    http://www.vbaexpress.com/forum/faq...._new_faq_item3

Posting Permissions

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