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

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
Murray BrownMicrosoft Cloud Azure/Excel Solution DeveloperAsked:
Who is Participating?
 
CodeCruiserConnect With a Mentor Commented:
Is that not the desired outcome. You have a condition which checks that the file is not xlsm before calling startup function.
0
 
CodeCruiserCommented:
What happens with above code?
0
 
Murray BrownMicrosoft Cloud Azure/Excel Solution DeveloperAuthor 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.
0
 
Murray BrownMicrosoft Cloud Azure/Excel Solution DeveloperAuthor Commented:
Yes. Agreed
0
All Courses

From novice to tech pro — start learning today.