Solved

In Excel97 how disable macros in opened workbook programmatically

Posted on 2002-03-19
5
262 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

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

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

Some time ago I was asked to create a VBA function that would calculate a check digit for an input number, using the following procedure: First, sum up all the individual digits in the number If that sum value has more than one digit, then sum up …
No matter the version of Windows you are using, you may have some problems with Windows Search running too slow or possibly not running at all. Before jumping into how you can solve this issue, just know there are many other viable alternative deskt…
This video walks the viewer through the process of creating Hyperlinks for the web and other documents. Select the "Insert" tab: Click "Hyperlink":  Type "http://" followed by a web address to reference a website or navigate to a document to ref…
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…

831 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