ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Executing Macro when Workbook is Open (https://www.excelbanter.com/excel-programming/384746-executing-macro-when-workbook-open.html)

Fredriksson via OfficeKB.com

Executing Macro when Workbook is Open
 
How do I automaticaly execute a Macro when a Workbook is Open?

--
Message posted via http://www.officekb.com


Gary''s Student

Executing Macro when Workbook is Open
 
Use an Event Macro:

http://www.cpearson.com/excel/events.htm
--
Gary''s Student
gsnu200709


"Fredriksson via OfficeKB.com" wrote:

How do I automaticaly execute a Macro when a Workbook is Open?

--
Message posted via http://www.officekb.com



Bob Phillips

Executing Macro when Workbook is Open
 
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)



"Fredriksson via OfficeKB.com" <u27002@uwe wrote in message
news:6ed59182df8ff@uwe...
How do I automaticaly execute a Macro when a Workbook is Open?

--
Message posted via http://www.officekb.com




Fredriksson via OfficeKB.com

Executing Macro when Workbook is Open
 
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

Bob Phillips wrote:
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

How do I automaticaly execute a Macro when a Workbook is Open?


--
Message posted via http://www.officekb.com


Bob Phillips

Executing Macro when Workbook is Open
 
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)



"Fredriksson via OfficeKB.com" <u27002@uwe wrote in message
news:6ee223bf61d00@uwe...
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

Bob Phillips wrote:
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

How do I automaticaly execute a Macro when a Workbook is Open?


--
Message posted via http://www.officekb.com




Fredriksson via OfficeKB.com

Executing Macro when Workbook is Open
 
I did not understood what you meant by This Workbook but I do now. Thanks for
all of your help. It is working

Bob Phillips wrote:
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]

How do I automaticaly execute a Macro when a Workbook is Open?


--
Message posted via http://www.officekb.com



All times are GMT +1. The time now is 11:03 AM.

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