Executing Macro when Workbook is Open

  • Thread starter Thread starter Fredriksson via OfficeKB.com
  • Start date Start date
Private Sub Workbook_Open()
'your code
End Sub

'This is workbook event code.
'To input this code, right click on the Excel icon on the worksheet
'(or next to the File menu if you maximise your workbooks),
'select View Code from the menu, and paste the code

--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)
 
I placed this code in my module1 at the end. It does not execute when My
workbook is opened.
Is there something I am missing?

Private Sub Workbook_Open()
Sheets("AP4301").Select
ActiveWorkbook.Names.Add Name:="Company", RefersToR1C1:="=AP4301!R1C2"
ActiveWorkbook.Names.Add Name:="AcctgPeriod", RefersToR1C1:="=AP4301!
R2C2"
ActiveWorkbook.Names.Add Name:="Vendor", RefersToR1C1:="=AP4301!R5C2"
ActiveWorkbook.Names.Add Name:="OccurDate", RefersToR1C1:="=AP4301!R11C2"
ActiveWorkbook.Names.Add Name:="Approver", RefersToR1C1:="=AP4301!R19C2"
ActiveWorkbook.Names.Add Name:="RowsToClear", RefersToR1C1:= _
"=AP4301!R23:R65536"
Sheets("Xref Property").Select
ActiveWorkbook.Names.Add Name:="PropertyKey", RefersToR1C1:= _
"='Xref Property'!R2C1"
Sheets("Xref COA").Select
ActiveWorkbook.Names.Add Name:="COAkey", RefersToR1C1:="='Xref COA'!R2C2"
MenuForm.Show
End Sub
 
Did you put it in ThisWorkbook as I described.

--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)
 
I did not understood what you meant by This Workbook but I do now. Thanks for
all of your help. It is working

Bob said:
Did you put it in ThisWorkbook as I described.
I placed this code in my module1 at the end. It does not execute when My
workbook is opened.
[quoted text clipped - 31 lines]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top