Excel 2003; Open & Disable macros

  • Thread starter Thread starter Jon
  • Start date Start date
J

Jon

Could anyone tell me how to use VBA (Excel) to open a file but DISABL
macros as it does.

An old Excel 97 workbook has a worksheet.calculate formula that resize
columns; but it keeps crashing the macro.

Private Sub Worksheet_Calculate()

Cells.Select ' <-- This crashes the macro in 2003 but not '97?!
Cells.EntireColumn.AutoFit

...etc.



What I'd like to be able to do is to open their file but disable thei
<old> macros.

bit like this

workbook.open := "blah blah" Macrodisable = TRUE

or something like that.

Pls help
 
Hi Jon,
Could anyone tell me how to use VBA (Excel) to open a file but DISABLE
macros as it does.

An old Excel 97 workbook has a worksheet.calculate formula that resizes
columns; but it keeps crashing the macro.

Private Sub Worksheet_Calculate()

Cells.Select ' <-- This crashes the macro in 2003 but not '97?!
Cells.EntireColumn.AutoFit

...etc.

What I'd like to be able to do is to open their file but disable their
<old> macros.

bit like this

workbook.open := "blah blah" Macrodisable = TRUE

One way would be by disabling events before opening:

Application.EnableEvents=False
Workbooks.Open.....

Make sure you set that property back to true after you have finished
working with that particular workbook, otherwise other (possibly needed)
events will not work either, it is an application-wide setting.

Regards,

Jan Karel Pieterse
Excel MVP
www.jkp-ads.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top