Solved

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

Posted on 2012-12-30
4
541 Views
Last Modified: 2012-12-30
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
0
Comment
Question by:murbro
  • 2
  • 2
4 Comments
 
LVL 83

Expert Comment

by:CodeCruiser
Comment Utility
What happens with above code?
0
 

Author Comment

by:murbro
Comment Utility
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
 
LVL 83

Accepted Solution

by:
CodeCruiser earned 500 total points
Comment Utility
Is that not the desired outcome. You have a condition which checks that the file is not xlsm before calling startup function.
0
 

Author Closing Comment

by:murbro
Comment Utility
Yes. Agreed
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

A little background as to how I came to I design this code: Around 5 years ago I designed an add-in that formatted Excel files to a corporate standard, applying different cell colours and font type depending on whether the cells contained inputs,…
INDEX and MATCH can be used to great effect to replace HLOOKUP and VLOOKUP as it does not have the limitation of needing the data to be sorted so that the reference value is in the first column or row. It also has the ability to perform a bi-directi…
The viewer will learn how to simulate a series of sales calls dependent on a single skill level and learn how to simulate a series of sales calls dependent on two skill levels. Simulating Independent Sales Calls: Enter .75 into cell C2 – “skill leve…
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now