Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I have built a workbook that call subroutines in an add-in (.xla). If the
workbook is run on another PC for the first time I get the above compile error, because the add-in is missing and my workbook code crashes. Is it possible to check in a macro that the add-in is present and exit gracefully (perhaps displaying a message saying the Add-in is missing)? -- Trefor |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
If you've set a reference in your workbook to the add-in there is no way to
trap an error if it is not present, as far as I know. But if you're running add-in code in some other way (like using RUN) you could check whether the add-in is open like this first: Function AddinPresent() As Boolean Dim WBName As String On Error GoTo NotPresent WBName = Workbooks("YourAddin.xla").Name AddinPresent = True NotPresent: End Function -- Jim "Trefor" wrote in message ... |I have built a workbook that call subroutines in an add-in (.xla). If the | workbook is run on another PC for the first time I get the above compile | error, because the add-in is missing and my workbook code crashes. Is it | possible to check in a macro that the add-in is present and exit gracefully | (perhaps displaying a message saying the Add-in is missing)? | | -- | Trefor |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Jim,
Thankyou for the reply. I have set a reference to a .xla, I have not used the RUN method before, if I did what are the disadvantages if I changed everytrhing to use RUN? (I presume you are talking about a .xlm?) I have no idea how to even create one of these. Life wasn't meant to be easy was it? Trefor -- Trefor "Jim Rech" wrote: If you've set a reference in your workbook to the add-in there is no way to trap an error if it is not present, as far as I know. But if you're running add-in code in some other way (like using RUN) you could check whether the add-in is open like this first: Function AddinPresent() As Boolean Dim WBName As String On Error GoTo NotPresent WBName = Workbooks("YourAddin.xla").Name AddinPresent = True NotPresent: End Function -- Jim "Trefor" wrote in message ... |I have built a workbook that call subroutines in an add-in (.xla). If the | workbook is run on another PC for the first time I get the above compile | error, because the add-in is missing and my workbook code crashes. Is it | possible to check in a macro that the add-in is present and exit gracefully | (perhaps displaying a message saying the Add-in is missing)? | | -- | Trefor |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I don't know of any disadvantage except that it's a little more cumbersome
to call a sub via Run than directly. In theory Run is a little slower but I don't see a difference as a practical matter. I don't know what you mean by "xlm". All I'm saying is replace a direct call to the add-in's sub: SubInXLA with Run "MyAddin.xla!SubInXLA" Of course this requires that the add-in is open in Excel. It will take you only a few seconds to switch one or two call and test how it works for you. check out the Run method for moe on it. -- Jim "Trefor" wrote in message ... | Jim, | | Thankyou for the reply. I have set a reference to a .xla, I have not used | the RUN method before, if I did what are the disadvantages if I changed | everytrhing to use RUN? (I presume you are talking about a .xlm?) I have no | idea how to even create one of these. | | Life wasn't meant to be easy was it? | | Trefor | -- | Trefor | | | "Jim Rech" wrote: | | If you've set a reference in your workbook to the add-in there is no way to | trap an error if it is not present, as far as I know. But if you're running | add-in code in some other way (like using RUN) you could check whether the | add-in is open like this first: | | Function AddinPresent() As Boolean | Dim WBName As String | On Error GoTo NotPresent | WBName = Workbooks("YourAddin.xla").Name | AddinPresent = True | NotPresent: | End Function | | -- | Jim | "Trefor" wrote in message | ... | |I have built a workbook that call subroutines in an add-in (.xla). If the | | workbook is run on another PC for the first time I get the above compile | | error, because the add-in is missing and my workbook code crashes. Is it | | possible to check in a macro that the add-in is present and exit | gracefully | | (perhaps displaying a message saying the Add-in is missing)? | | | | -- | | Trefor | | | |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Jim,
Thank you again for your reply. But I am still having problems: This is the main workbook: Option Explicit Option Private Module Public Const DCMaster = "Customer Data Collect Master v6.37.xla" Sub Auto_Open() If AddinPresent Then Application.Run DCMaster & "!test" <----- This says it can't find the macro Else MsgBox "Addin Not Present" End If End Sub Function AddinPresent() As Boolean <----- This works great thankyou Dim WBName As String On Error GoTo NotPresent WBName = Workbooks(DCMaster).Name AddinPresent = True NotPresent: End Function This is the macro in the .xla: Public Sub test() MsgBox "test" End Sub Trefor -- Trefor "Jim Rech" wrote: I don't know of any disadvantage except that it's a little more cumbersome to call a sub via Run than directly. In theory Run is a little slower but I don't see a difference as a practical matter. I don't know what you mean by "xlm". All I'm saying is replace a direct call to the add-in's sub: SubInXLA with Run "MyAddin.xla!SubInXLA" Of course this requires that the add-in is open in Excel. It will take you only a few seconds to switch one or two call and test how it works for you. check out the Run method for moe on it. -- Jim "Trefor" wrote in message ... | Jim, | | Thankyou for the reply. I have set a reference to a .xla, I have not used | the RUN method before, if I did what are the disadvantages if I changed | everytrhing to use RUN? (I presume you are talking about a .xlm?) I have no | idea how to even create one of these. | | Life wasn't meant to be easy was it? | | Trefor | -- | Trefor | | | "Jim Rech" wrote: | | If you've set a reference in your workbook to the add-in there is no way to | trap an error if it is not present, as far as I know. But if you're running | add-in code in some other way (like using RUN) you could check whether the | add-in is open like this first: | | Function AddinPresent() As Boolean | Dim WBName As String | On Error GoTo NotPresent | WBName = Workbooks("YourAddin.xla").Name | AddinPresent = True | NotPresent: | End Function | | -- | Jim | "Trefor" wrote in message | ... | |I have built a workbook that call subroutines in an add-in (.xla). If the | | workbook is run on another PC for the first time I get the above compile | | error, because the add-in is missing and my workbook code crashes. Is it | | possible to check in a macro that the add-in is present and exit | gracefully | | (perhaps displaying a message saying the Add-in is missing)? | | | | -- | | Trefor | | | |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Tefor,
Application.Run DCMaster & "!test" <----- This says it can't find Look at the syntax suggested by Jim and look at the Run method in VBA help. Try: Application.Run "DCMaster.xla!test" --- Regards, Norman "Trefor" wrote in message ... Jim, Thank you again for your reply. But I am still having problems: This is the main workbook: Option Explicit Option Private Module Public Const DCMaster = "Customer Data Collect Master v6.37.xla" Sub Auto_Open() If AddinPresent Then Application.Run DCMaster & "!test" <----- This says it can't find the macro Else MsgBox "Addin Not Present" End If End Sub Function AddinPresent() As Boolean <----- This works great thankyou Dim WBName As String On Error GoTo NotPresent WBName = Workbooks(DCMaster).Name AddinPresent = True NotPresent: End Function This is the macro in the .xla: Public Sub test() MsgBox "test" End Sub Trefor -- Trefor "Jim Rech" wrote: I don't know of any disadvantage except that it's a little more cumbersome to call a sub via Run than directly. In theory Run is a little slower but I don't see a difference as a practical matter. I don't know what you mean by "xlm". All I'm saying is replace a direct call to the add-in's sub: SubInXLA with Run "MyAddin.xla!SubInXLA" Of course this requires that the add-in is open in Excel. It will take you only a few seconds to switch one or two call and test how it works for you. check out the Run method for moe on it. -- Jim |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Compile error: Can't find project or library | New Users to Excel | |||
Compile error: Can't find project or library | Excel Programming | |||
Compile error: Can't find project or library | Excel Programming | |||
Compile Error, Can'f Find Project or Library | Excel Programming | |||
Compile Error! Can't find project or Library --- Help! | Excel Programming |