PDA

View Full Version : Stop macros



mdmackillop
02-17-2006, 02:41 PM
I'm using this code to insert various file types as an object in Excel. Is there a way to stop the file from trying to run any autorun macros?

ActiveSheet.OLEObjects.Add(Filename:=FName).Select
With Selection
.ShapeRange.Left = [D1].Left
.ShapeRange.Top = Cells(ActiveWindow.ScrollRow + 1, 4).Top
.ShapeRange.Width = 400
End With

XLGibbs
02-17-2006, 02:43 PM
You might have to duplicate the manual method of holding down Shift while opening the file or something....if it can be done manually...it can be done in code is usually the thought process I take.

I am unfamiliar with the exact steps needed to "stop" and AUto_Open macro...

johnske
02-17-2006, 04:34 PM
Hi Malcolm,

Wouldn't Application.EnableEvents = False do what you want?

John :)

mdmackillop
02-17-2006, 04:37 PM
Hi John,
If you think I would miss something as simple as that, you're absolutely right!
I'll check it out tomorrow.
Regards
Malcolm

XLGibbs
02-17-2006, 05:10 PM
LOL, I assumed you had tried that already and it didn't work!

mdmackillop
02-17-2006, 06:30 PM
Events are disabled in Excel, but not disabled in the application to be opened. Ideally, the macro warnings should not appear either. All I really want is a "snapshot" of the document, or whatever.
The query relates to this posting
http://vbaexpress.com/forum/showpost.php?p=57801&postcount=15

XLGibbs
02-17-2006, 06:51 PM
You can use the excel viewer if it is for excel 2003 maybe, but maybe you bypass it with a pop up asking if they want to preview the file before any action is taken?