Excel Add-in VB.net - determine if active workbook has macros

Murray Brown
Murray Brown used Ask the Experts™
on
Hi

I have quite a complicated add-in the causes strange errors if i open Excel by opening
a .xlsm file. I need to determine if the ActiveWorkbook is a .xlsm file.
How do I do this?

    Private Sub ThisAddIn_Startup() Handles Me.Startup

        If Globals.ThisAddIn.Application.ActiveWorkbook.FileFormat.ToString <> "52" Then
            oAddInStartUp()
        End If

    End Sub
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Most Valuable Expert 2012
Top Expert 2014

Commented:
What happens with above code?
Murray BrownASP.net/VBA/VSTO Developer

Author

Commented:
If it is a .xlsm it doesn't load my add-in. I have to go into the Option Add-ins section and select COM Add-ins then re-check the box to make it available as the system unchecks this.
Most Valuable Expert 2012
Top Expert 2014
Commented:
Is that not the desired outcome. You have a condition which checks that the file is not xlsm before calling startup function.
Murray BrownASP.net/VBA/VSTO Developer

Author

Commented:
Yes. Agreed

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial