Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 51
Default 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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default 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


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default 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



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 51
Default 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

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default 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





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 51
Default 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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Open workbook macro- find correct month to open? buzzharley[_10_] Excel Programming 8 July 8th 06 04:30 AM
Executing a macro in a closed workbook Alex Excel Programming 0 June 20th 05 03:35 PM
Problem executing a macro from different workbook where it is Sergio Calleja Excel Discussion (Misc queries) 1 January 17th 05 12:38 PM
File Already Open Error When Executing A Macro Chuckles123[_26_] Excel Programming 0 October 7th 04 06:20 PM
File Already Open Error When Executing A Macro Chuckles123[_25_] Excel Programming 0 October 7th 04 05:48 PM


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

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"