ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Macro in 2nd Open workbook (https://www.excelbanter.com/excel-discussion-misc-queries/174681-macro-2nd-open-workbook.html)

Steve

Macro in 2nd Open workbook
 
Is it possible to open Workbook1 with macros allowed but then open Workbook2,
from within Workbook1, but with macros disabled? I really only am trying to
copy data from Workbook2 to Workbook1 and don't need the "Open workbook"
macro to run in Workbook2. It just really slows down the copy process

Dave Peterson

Macro in 2nd Open workbook
 
You can disable events before you open the second workbook to prevent the
workbook_open from firing:

Dim wkbk1 as workbook
dim wkbk2 as workbook

set wkbk1 = workbooks.open(filename:=....)

application.enableevents = false
set wkbk2 = workbooks.open(filename:=....)
application.enableevents = true

Depending on what you're doing, you may want to turn off events before you do
anything with that second workbook to keep all events from firing in that
workbook.

Steve wrote:

Is it possible to open Workbook1 with macros allowed but then open Workbook2,
from within Workbook1, but with macros disabled? I really only am trying to
copy data from Workbook2 to Workbook1 and don't need the "Open workbook"
macro to run in Workbook2. It just really slows down the copy process


--

Dave Peterson


All times are GMT +1. The time now is 03:45 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com