![]() |
Opening workbook with OpenEvent
Hi All
I have a number of workbooks I wish to extract data from, the extract routine is in another control workbook that opens each in sequence copies the data into the control book. My problem is that each of the workbooks I am opening contains a workbook_open event that loads a userform. (Excel 97). How do I either prevent the workbook open event happening or close the userform in the newly opened workbook so that I can copy data and then close it? -- Cheers Nigel |
Opening workbook with OpenEvent
Disable events for as long as you need to:
dim wkbk as workbook application.enableevents = false set wkbk = workbooks.open(filename:=...., updatelinks:=???) 'do anything you want wkbk.close savechanges:=false application.enableevents = true If you re-enable events, you could get workbook_beforeclose and worksheet_change events to fire (which could be a good thing if you want them to fire). Nigel wrote: Hi All I have a number of workbooks I wish to extract data from, the extract routine is in another control workbook that opens each in sequence copies the data into the control book. My problem is that each of the workbooks I am opening contains a workbook_open event that loads a userform. (Excel 97). How do I either prevent the workbook open event happening or close the userform in the newly opened workbook so that I can copy data and then close it? -- Cheers Nigel -- Dave Peterson |
Opening workbook with OpenEvent
Many thanks
-- Cheers Nigel "Dave Peterson" wrote in message ... Disable events for as long as you need to: dim wkbk as workbook application.enableevents = false set wkbk = workbooks.open(filename:=...., updatelinks:=???) 'do anything you want wkbk.close savechanges:=false application.enableevents = true If you re-enable events, you could get workbook_beforeclose and worksheet_change events to fire (which could be a good thing if you want them to fire). Nigel wrote: Hi All I have a number of workbooks I wish to extract data from, the extract routine is in another control workbook that opens each in sequence copies the data into the control book. My problem is that each of the workbooks I am opening contains a workbook_open event that loads a userform. (Excel 97). How do I either prevent the workbook open event happening or close the userform in the newly opened workbook so that I can copy data and then close it? -- Cheers Nigel -- Dave Peterson |
All times are GMT +1. The time now is 01:53 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com