Opening Excel & Addin

G

Geoff

I have an Excel addin that if Excel is not open I just want to open the
addin and Excel at the same time. Is there a way to do this through VB or
VBA? This would be similar to say double clicking on the XLA through
explorer.

Thanks in advance
 
B

Bob Phillips

Sub OpenAddin()
Dim oXL As Object
Dim oAI As Object

On Error Resume Next
Set oXL = GetObject(, "Excel.Application")
If oXL Is Nothing Then
Set oXL = CreateObject("Excel.Application")
If Not oXL Is Nothing Then
Set oAI = oXL.Workbooks.Open(Filename:="C:\myTest\m yAddin.xla")
If oAI Is Nothing Then
MsgBox "Failed to open add-in"
End If
Else
MsgBox "failed to start Excel"
End If
End If
On Error GoTo 0

End Sub
 
Top