ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Finding xla (https://www.excelbanter.com/excel-programming/402293-finding-xla.html)

fred

Finding xla
 
I'm running Office 2007 and would like to how to test if a particular Excel
addin (.xla) is already open within the current application.
I have tried finding it as a workbook (see below) but .xla files are not
included in the workbooks collection.

Dim WB as Workbook, WA as Workbook
For Each WB in Application.Workbooks
If WB.Name = "MyAddin.xla" then
Set WA = WB
Exit For
End if
Next WB
If Not WA is Nothing then ...



Dave Peterson

Finding xla
 
Dim wb As Workbook

Set wb = Nothing
On Error Resume Next
Set wb = Workbooks("personal.xla")
On Error GoTo 0

If wb Is Nothing Then
MsgBox "not open"
Else
MsgBox wb.FullName
End If

Fred wrote:

I'm running Office 2007 and would like to how to test if a particular Excel
addin (.xla) is already open within the current application.
I have tried finding it as a workbook (see below) but .xla files are not
included in the workbooks collection.

Dim WB as Workbook, WA as Workbook
For Each WB in Application.Workbooks
If WB.Name = "MyAddin.xla" then
Set WA = WB
Exit For
End if
Next WB
If Not WA is Nothing then ...


--

Dave Peterson

Tim Zych

Finding xla
 
I like Dave's suggestion because it works consistently for addins and
workbooks, but if you want to enumerate opened addins, here is another way:

Dim ai As AddIn
Dim wb as Workbook
For Each ai In Application.AddIns
If ai.Installed = True And ai.Name = "MyAddin.xla" Then
Set wb = Workbooks(ai.Name)
Exit For
End If
Next

--
Tim Zych
SF, CA

"Fred" <leavemealone@home wrote in message
...
I'm running Office 2007 and would like to how to test if a particular
Excel addin (.xla) is already open within the current application.
I have tried finding it as a workbook (see below) but .xla files are not
included in the workbooks collection.

Dim WB as Workbook, WA as Workbook
For Each WB in Application.Workbooks
If WB.Name = "MyAddin.xla" then
Set WA = WB
Exit For
End if
Next WB
If Not WA is Nothing then ...






All times are GMT +1. The time now is 11:24 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com