Solved

In Excel97 how disable macros in opened workbook programmatically

Posted on 2002-03-19
5
265 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

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

You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
If you need to forecast numbers -- typically for finance -- the Windows and Mac versions of Excel 2016 have a basket of tools to get the job done.
This video walks the viewer through the process of creating envelopes and labels, with multiple names and addresses. Navigate to the “Start Mail Merge” button in the Mailings tab: Follow the step-by-step process until asked to find the address doc…
This video shows where to find the word count, how to display it, and what it breaks down to in Microsoft Word.

630 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