+ Reply to Thread
Results 1 to 4 of 4

Problems loading and AddIn

Hybrid View

  1. #1
    Trefor
    Guest

    Problems loading and AddIn

    Below is a snippet of my code thanks to this forum. I am getting an Error =9
    on the line marked *1, so I try and load the Addin, the below code completes
    without error, but the AddIn didnot load. This code has been working for
    about 10months now, I can't understand why it is not working now, any ideas?

    Dim WBName As String
    On Error Resume Next ' turn off error checking
    *1 WBName = Workbooks(DCMaster2).Name ' Check to see if AddIn is loaded
    and should return an error if the file is not loaded
    LastError = Err
    On Error GoTo 0 ' restore error checking
    If LastError <> 0 Then
    ' the add-in workbook isn't currently open. Manually open it.
    ' On Error Resume Next
    Application.DisplayAlerts = False
    With AddIns.Add(Filename:=Application.UserLibraryPath & DCMaster2)
    .Installed = True
    End With

    --
    Trefor

  2. #2
    NickHK
    Guest

    Re: Problems loading and AddIn

    One thing, Err is an Object with various properties etc
    I think you are looking for
    LastError = Err.Number

    NickHK

    "Trefor" <Trefor@home.com> wrote in message
    news:E9375308-1ABE-4B17-8E92-3D57D83E47D0@microsoft.com...
    > Below is a snippet of my code thanks to this forum. I am getting an Error

    =9
    > on the line marked *1, so I try and load the Addin, the below code

    completes
    > without error, but the AddIn didnot load. This code has been working for
    > about 10months now, I can't understand why it is not working now, any

    ideas?
    >
    > Dim WBName As String
    > On Error Resume Next ' turn off error checking
    > *1 WBName = Workbooks(DCMaster2).Name ' Check to see if AddIn is

    loaded
    > and should return an error if the file is not loaded
    > LastError = Err
    > On Error GoTo 0 ' restore error checking
    > If LastError <> 0 Then
    > ' the add-in workbook isn't currently open. Manually open it.
    > ' On Error Resume Next
    > Application.DisplayAlerts = False
    > With AddIns.Add(Filename:=Application.UserLibraryPath & DCMaster2)
    > .Installed = True
    > End With
    >
    > --
    > Trefor




  3. #3
    NickHK
    Guest

    Re: Problems loading and AddIn

    This is why it's a good practice to Dim all your variable (preferably using
    Option Excpicit).
    At compile time the error would have come to light.

    NickHK

    "NickHK" <TungCheWah@Invalid.com> ¼¶¼g©ó¶l¥ó·s»D:%231NPzqqwGHA.1484@TK2MSFTNGP04.phx.gbl...
    > One thing, Err is an Object with various properties etc
    > I think you are looking for
    > LastError = Err.Number
    >
    > NickHK
    >
    > "Trefor" <Trefor@home.com> wrote in message
    > news:E9375308-1ABE-4B17-8E92-3D57D83E47D0@microsoft.com...
    >> Below is a snippet of my code thanks to this forum. I am getting an Error

    > =9
    >> on the line marked *1, so I try and load the Addin, the below code

    > completes
    >> without error, but the AddIn didnot load. This code has been working for
    >> about 10months now, I can't understand why it is not working now, any

    > ideas?
    >>
    >> Dim WBName As String
    >> On Error Resume Next ' turn off error checking
    >> *1 WBName = Workbooks(DCMaster2).Name ' Check to see if AddIn is

    > loaded
    >> and should return an error if the file is not loaded
    >> LastError = Err
    >> On Error GoTo 0 ' restore error checking
    >> If LastError <> 0 Then
    >> ' the add-in workbook isn't currently open. Manually open it.
    >> ' On Error Resume Next
    >> Application.DisplayAlerts = False
    >> With AddIns.Add(Filename:=Application.UserLibraryPath &
    >> DCMaster2)
    >> .Installed = True
    >> End With
    >>
    >> --
    >> Trefor

    >
    >




  4. #4
    Trefor
    Guest

    Re: Problems loading and AddIn

    NickHK,

    All of my modules are marked with "Option Explicit". I have used the Err to
    get the Error number for years and it has always work for me. Besides if I
    completely shutdown Excel and start again it works fine.

    --
    Trefor


    "NickHK" wrote:

    > This is why it's a good practice to Dim all your variable (preferably using
    > Option Excpicit).
    > At compile time the error would have come to light.
    >
    > NickHK
    >
    > "NickHK" <TungCheWah@Invalid.com> ¼¶¼g©ó¶l¥ó·s»D:%231NPzqqwGHA.1484@TK2MSFTNGP04.phx.gbl...
    > > One thing, Err is an Object with various properties etc
    > > I think you are looking for
    > > LastError = Err.Number
    > >
    > > NickHK
    > >
    > > "Trefor" <Trefor@home.com> wrote in message
    > > news:E9375308-1ABE-4B17-8E92-3D57D83E47D0@microsoft.com...
    > >> Below is a snippet of my code thanks to this forum. I am getting an Error

    > > =9
    > >> on the line marked *1, so I try and load the Addin, the below code

    > > completes
    > >> without error, but the AddIn didnot load. This code has been working for
    > >> about 10months now, I can't understand why it is not working now, any

    > > ideas?
    > >>
    > >> Dim WBName As String
    > >> On Error Resume Next ' turn off error checking
    > >> *1 WBName = Workbooks(DCMaster2).Name ' Check to see if AddIn is

    > > loaded
    > >> and should return an error if the file is not loaded
    > >> LastError = Err
    > >> On Error GoTo 0 ' restore error checking
    > >> If LastError <> 0 Then
    > >> ' the add-in workbook isn't currently open. Manually open it.
    > >> ' On Error Resume Next
    > >> Application.DisplayAlerts = False
    > >> With AddIns.Add(Filename:=Application.UserLibraryPath &
    > >> DCMaster2)
    > >> .Installed = True
    > >> End With
    > >>
    > >> --
    > >> Trefor

    > >
    > >

    >
    >
    >


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1