Excel 2003; Open & Disable macros

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
 
J

Jan Karel Pieterse

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
 
Top