Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 30
Default Deactivating auto macros

Hi everyone,

Is it possible to deactivate auto macros when I open a workbook in VBA?

Thanks.
--
Jac Tremblay
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Deactivating auto macros

Hold down the SHIFT key when you open the workbook.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"Jac Tremblay" wrote in
message
...
Hi everyone,

Is it possible to deactivate auto macros when I open a workbook
in VBA?

Thanks.
--
Jac Tremblay



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 30
Default Deactivating auto macros

Hi Chip,

I know that trick, but my macro opens 60 workbooks from a folder and I want
to deactivate those macros in VBA.

Workbooks.Open Filename:=strTemplatePath & strTemplateName

Thanks.

"Chip Pearson" wrote:

Hold down the SHIFT key when you open the workbook.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"Jac Tremblay" wrote in
message
...
Hi everyone,

Is it possible to deactivate auto macros when I open a workbook
in VBA?

Thanks.
--
Jac Tremblay




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Deactivating auto macros

The Auto_Open macro will not run if the workbook is opened by
VBA. To disable the Workbook_Open event procedure, use

Application.EnableEvents = False
' open the workbook
Application.EnableEvents = True


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com




"Jac Tremblay" wrote in
message
...
Hi Chip,

I know that trick, but my macro opens 60 workbooks from a
folder and I want
to deactivate those macros in VBA.

Workbooks.Open Filename:=strTemplatePath & strTemplateName

Thanks.

"Chip Pearson" wrote:

Hold down the SHIFT key when you open the workbook.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"Jac Tremblay" wrote
in
message
...
Hi everyone,

Is it possible to deactivate auto macros when I open a
workbook
in VBA?

Thanks.
--
Jac Tremblay






  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 30
Default Deactivating auto macros

Hi Chip,

This seems to do the job. I will check it out a bit more tomorrow.

Thank you for your time.


"Chip Pearson" wrote:

The Auto_Open macro will not run if the workbook is opened by
VBA. To disable the Workbook_Open event procedure, use

Application.EnableEvents = False
' open the workbook
Application.EnableEvents = True


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com




"Jac Tremblay" wrote in
message
...
Hi Chip,

I know that trick, but my macro opens 60 workbooks from a
folder and I want
to deactivate those macros in VBA.

Workbooks.Open Filename:=strTemplatePath & strTemplateName

Thanks.

"Chip Pearson" wrote:

Hold down the SHIFT key when you open the workbook.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"Jac Tremblay" wrote
in
message
...
Hi everyone,

Is it possible to deactivate auto macros when I open a
workbook
in VBA?

Thanks.
--
Jac Tremblay








  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Deactivating auto macros

Can you tell me how to open the workbook by VBA? I have incorrect logic in
the macro which is run in the open event, so my macro updates the wrong
sheet. I don't want to have to retype all the correct informaton in this
sheet so I'd like to disable this macro and then fix it.

"Chip Pearson" wrote:

The Auto_Open macro will not run if the workbook is opened by
VBA. To disable the Workbook_Open event procedure, use

Application.EnableEvents = False
' open the workbook
Application.EnableEvents = True


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com




"Jac Tremblay" wrote in
message
...
Hi Chip,

I know that trick, but my macro opens 60 workbooks from a
folder and I want
to deactivate those macros in VBA.

Workbooks.Open Filename:=strTemplatePath & strTemplateName

Thanks.

"Chip Pearson" wrote:

Hold down the SHIFT key when you open the workbook.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"Jac Tremblay" wrote
in
message
...
Hi everyone,

Is it possible to deactivate auto macros when I open a
workbook
in VBA?

Thanks.
--
Jac Tremblay






  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 26
Default Deactivating auto macros

Hi Jebeh -

I know you posted this awhile ago, but I found Chip Pearson's answer useful
and saw your post so I decided to try to help.

The general was to open a workbook in VBA is

Workbooks.Open(fileName)

As far as disabling macros to open the workbook, you can probably get away
with

Application.EnableEvents=False
Workbooks.Open(fileName)


However, here is an even fancier way that I came up with and works really
well. This uses Excel Automation. Try This:

Sub test_Automation_Open_WB()
Dim XL As Excel.Application
Dim wb As Workbook
Dim fileName As String
Dim wb_Name As String

wb_Name = "TEST__someStuff.xls"

fileName = ThisWorkbook.Path & "\" & wb_Name

Set XL = CreateObject("Excel.Application")

With XL
.EnableEvents = False
.Visible = True

Set wb = XL.Workbooks.Open(fileName, False)
End With
End Sub

This should easily do all you need. It will open a new application of Excel
and then your workbook and will suppress all workbook.open events and pop-ups
to disable macros, etc.

Hope that helps,

Best Regards,

Chris )





"Jebeh" wrote:

Can you tell me how to open the workbook by VBA? I have incorrect logic in
the macro which is run in the open event, so my macro updates the wrong
sheet. I don't want to have to retype all the correct informaton in this
sheet so I'd like to disable this macro and then fix it.

"Chip Pearson" wrote:

The Auto_Open macro will not run if the workbook is opened by
VBA. To disable the Workbook_Open event procedure, use

Application.EnableEvents = False
' open the workbook
Application.EnableEvents = True


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com




"Jac Tremblay" wrote in
message
...
Hi Chip,

I know that trick, but my macro opens 60 workbooks from a
folder and I want
to deactivate those macros in VBA.

Workbooks.Open Filename:=strTemplatePath & strTemplateName

Thanks.

"Chip Pearson" wrote:

Hold down the SHIFT key when you open the workbook.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"Jac Tremblay" wrote
in
message
...
Hi everyone,

Is it possible to deactivate auto macros when I open a
workbook
in VBA?

Thanks.
--
Jac Tremblay






Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Deactivating a macro button Victor Delta[_2_] Excel Discussion (Misc queries) 2 November 8th 09 02:07 PM
Deactivating an Excel Warning Bishop Excel Discussion (Misc queries) 1 May 29th 09 05:48 AM
Deactivating an embedded chart TheRobsterUK Excel Discussion (Misc queries) 0 October 3rd 05 01:30 AM
Deactivating worksheets Keri[_2_] Excel Programming 3 August 31st 04 04:50 PM
Error Msg Deactivating Code Phil Hageman Excel Programming 3 October 2nd 03 03:49 PM


All times are GMT +1. The time now is 10:20 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"