ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Workbook_BeforeClose Event (https://www.excelbanter.com/excel-programming/288920-workbook_beforeclose-event.html)

Shatin

Workbook_BeforeClose Event
 
Hi all,

I have written a macro -- let's call it web_macro -- to import some
web pages into Excel. The macro then reformats the pages. It's all
done automatically. I then share the resulting file -- let's call it
"new_file" -- with my friends. The web_macro is in my personal.xls
file.

What I want is that whenever my friends close the new_file, a message
will be displayed. I know I can do it by adding a workbook_beforeclose
event to ThisWorkbook in the new_file. However, I don't want to do it
every time a new_file is generated. How can I code it in my original
web_macro so that a Workbook_BeforeClose event will be inserted to the
new_file automatically?

Your help will be much appreciated!

Beto[_3_]

Workbook_BeforeClose Event
 
Shatin wrote:

Hi all,

I have written a macro -- let's call it web_macro -- to import some
web pages into Excel. The macro then reformats the pages. It's all
done automatically. I then share the resulting file -- let's call it
"new_file" -- with my friends. The web_macro is in my personal.xls
file.

What I want is that whenever my friends close the new_file, a message
will be displayed. I know I can do it by adding a workbook_beforeclose
event to ThisWorkbook in the new_file. However, I don't want to do it
every time a new_file is generated. How can I code it in my original
web_macro so that a Workbook_BeforeClose event will be inserted to the
new_file automatically?


You can find information he
http://www.cpearson.com/excel/vbe.htm

Another way would be to use a template excel file with the code already
in. So you open it, import with web macro, then save as a different file.
Regards,
--
Beto
Reply: Erase between the dot (inclusive) and the @.
Responder: Borra la frase obvia y el punto previo.


Shatin

Workbook_BeforeClose Event
 
Beto, thanks for your help! I've successfully written the code by
following the advice on the cpearson page. Took me less than 2 minutes
to do it and the code ran as advertised the first time!


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

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