Finding xla

F

Fred

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 ...
 
D

Dave Peterson

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
 
T

Tim Zych

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top