View Single Post
  #10   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
Default VBA Open Wkbook Disabling Macros

Just to beat a dead horse...

Ron's suggestion of disabling events should stop any code from running in the
workbook that's being opened in code.

The only other way to run a macro in that second workbook is to explicitly call
it. And that's easy to avoid <vbg.

Karen53 wrote:

Hi Dave,

I want it to trust the opening workbook but not trust the workbook being
opened. It does work as you say, it trusts both workbooks. But, I don't
want the macros in the newly opened workbook to run. I think now it's not
possible, the macos are either on or off for all open workbooks.

Another question though, if my second workbook is already open, my code
does not process. If I have the code open the workbook, it processes. Do I
have something wrong?
--
Thanks for your help.
Karen53

"Dave Peterson" wrote:

This doesn't sound like excel's usual behavior to me.

If you're opening a workbook from code in another workbook's project, then excel
should already trust that workbook.

I don't have a suggestion why this is happening to you or how you can avoid it,
but something ain't normal.

If you create a couple of small workbooks and do a test, do you see the security
prompt?

Karen53 wrote:

Hi Ron,

Thank you for the reply.

Sorry, I wasn't clear with what I needed.

The workbook being opened comes up with the security window asking to
'Enable' or' Disable Macros'. I need to select 'Disable' with vba.
Application.EnableEvents is already false. Is there a way to do this?
--
Thanks for your help.
Karen53

"Ron de Bruin" wrote:

If you want to stop the events from running when you open a workbook with code you can use

Application.EnableEvents = False

Code

Application.EnableEvents = True


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Karen53" wrote in message ...
Hi,

I need to open a workbook with VBA and disable the macros. How would I do
this?

Workbooks.Open("C:\Documents and Settings\Me\Desktop\New
Workbooks\MywkBook.xls")
--
Thanks for your help.
Karen53


--

Dave Peterson


--

Dave Peterson