Solved

In Excel97 how disable macros in opened workbook programmatically

Posted on 2002-03-19
5
260 Views
Last Modified: 2008-02-01
I have an Excel97 workbook with several macros in it. The macros are designed to read in xls files from around 12 folders. Each Excel workbook is then processed to delete all but one specific sheet, delete all buttons, combo boxes etc from this sheet, and remove all VBA code. The workbooks are then saved again in another folder. The whole thing is a house keeping exercise deigned to save space on the server. The problem I have is that all the workbooks have macros which run when the workbook is opened. In some cases this can cause an error, so the process keeps being interrupted. I need to be able to disable the macros in the opening workbook before they get to run. Unfortunately there doesn't seem a way of doing this. I tried a number of combinations based around
code such as :-

    Workbooks.Open FileName:=FileNameInput, ReadOnly:=True, _
        disablemacros:=True
 but disablemacros is an invalid argument

HELP

 
0
Comment
Question by:macbone2
  • 3
  • 2
5 Comments
 
LVL 44

Expert Comment

by:bruintje
ID: 6880162
Hi macbone2,

you could start it like

Application.EnableEvents = False
    Workbooks.Open _
        FileName:=(Directory & MyFile)
    ' Do your processing
Application.EnableEvents = True

HTH:O)Bruintje
0
 
LVL 2

Author Comment

by:macbone2
ID: 6880403
Thanks Bruintje. It works a treat. Should have known it myself. Award yourself 100 points.
I'm posting another question tomorrow about removing some stubborn VBA macros programmatically. I've done it before, but there are 1 or 2 in each workbook which refuse to go. Never had the problem before.


Thanks again

Geoff McKeown (macbone2)
0
 
LVL 44

Expert Comment

by:bruintje
ID: 6880421
glad it worked! > to accept my answer you can use the accept comment as answer button......
0
 
LVL 2

Author Comment

by:macbone2
ID: 6881285
I already posted the 100 points Brian

Thanks

Geoff
0
 
LVL 44

Accepted Solution

by:
bruintje earned 100 total points
ID: 6881735
Hi Geoff, that's correct only i can't accept an answer for you ;)

if you look in the comment box where you found the solution there should be an <accept answer> label in the right corner, if you click there you can grade my comment into an answer and close this question as a PAQ (Previously Asked Question)

Only the member who asked the question can accept a comment as answer

I'll answer this and you can accept it ;) that's shorter so you can accpet my answer and grade it

<for PAQ readers answer is given above>

:O)Bruintje
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Article by: dandraka
There are several quick shortcuts that can make your life easier in Microsoft Programs.  These simple tips and tricks will your work more productive and you faster at completing your tasks! MS Word (1) Creating Re-usable Scraps You can create s…
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.
This video shows where to find the word count, how to display it, and what it breaks down to in Microsoft Word.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

744 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

10 Experts available now in Live!

Get 1:1 Help Now