Solved

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

Posted on 2012-12-30
4
542 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
ID: 38731496
What happens with above code?
0
 

Author Comment

by:murbro
ID: 38731512
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
ID: 38731542
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
ID: 38732074
Yes. Agreed
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.

863 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

18 Experts available now in Live!

Get 1:1 Help Now