MrExcel Publishing
Your One Stop for Excel Tips & Solutions

How do u call a function on Open & on Close


Posted by Phil on June 12, 2001 4:39 AM

Does any1 know how i would call these fuctions when the document is opened

BuildCustomToolbar()
HideUsersMenuBars()

and call this one when the user closes the work book
(or better still when the workbook is not in focus)

RemoveCustomToolBar()


Cheers

Phil


Posted by Dax on June 12, 2001 4:59 AM


Hello,
If you follow these steps you'll be able to have any custom procedures run automatically.

Open the VB Editor (Alt + F11)
Click View, Project Explorer
Double click the ThisWorkbook icon.

You'll see two drop-down boxes. Click the left one and choose Workbook. This will create an empty procedure that will automatically run when the workbook is opened. Click on the right drop-down box to see all of the events that you can write code in response to. If you just put the name of the procedure e.g.

Private Sub Workbook_Deactivate()
RemoveCustomToolBar
End Sub

Private Sub Workbook_Open()
BuildCustomToolbar
HideUsersMenuBars
End Sub

HTH,
Dax.