Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help me for "code module" in "ThisWorkbook" Object..

Status
Not open for further replies.

paragtek

Programmer
Apr 11, 2003
2
US
Hi all,

I am new to VBA Programming.

I want to put Workbook_Open() and Workbook_BeforeClose() functions of VBA Excel in Code module of ThisWorkbook object as written in one of the book I am refering to. But I don't know how go to to this "Code Module" of "ThisWorkbook" object.

Could anyone help me in this....any help regarding this will be highly apprciated.

Thanks in advance.

waiting....

Parag
 
Hi Parag

Press Alt F11 to get into VBA
On the left hand side of the screen you will see a list of all open workbooks.
Find the workbook you want to work with & underneath the name of the workbook is a folder called Microsoft Excel Objects if this has a plus sign to the left of it click this.
You should now have a list with something like
Sheet1(Sheet1)
Sheet1(Sheet1)
ThisWorkbook

Double click ThisWorkbook
On the right side of the screen you will ussually have a blank page & at the top will be two drop down lists ususally called (General) & (Declarations)
Click General and pick Workbook it will put a code module for Workbook_Open on the page if you now click the drop down list to the right of Workbook you can pick the BeforeWorkbook_Close procedure, or any of the others.

Sorry if this is a bit long winded, but if you get stuck give me your email address & I can send some screenshots

Simmy
 
Hello Simmy,

Thanks a lot for your help pal. :)
Actually, some how after searching in every corner of the VBE the same day, I got that "Code module" of "ThisWorkbook" object. But yes, your way of doing it is the proper one and easy to remember too.
Thank you again for giving your time to explain it step by step.

Regards,

Parag

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top