View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming,microsoft.public.word.vba.general
Gary Keramidas Gary Keramidas is offline
external usenet poster
 
Posts: 2,494
Default How do I prevent AutoRun Macros when Programmatically Opening Workbook?

use Private Sub Auto_Open in a general module instead of Private Sub
Workbook_Open() in thisworkbook.



--


Gary


"Joseph Geretz" wrote in message
...
I have an application which uses Word and Excel as automation servers. When
opening a document, I need to prevent macros from running automatically.

For Word documents I can do this as follows:

m_AppWord.WordBasic.DisableAutoMacros 1
Set m_DocWord = m_AppWord.Documents.Open(CStr(m_Document), False, True,
False)

What is the equivalent statement for Excel which I should be coding directly
before opening the file?

Set m_DocExcel = m_AppExcel.Workbooks.Open(CStr(m_Document))

Thanks for your help!

- Joseph Geretz