Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Is there an "OnOpen" event for Excel

Hi,
I wish to display a message box when a user opens the spreadsheet. How do I
make my message box code run? I have tried the following but it does not seem
to work:

Sub DisplayMessageBox()
If Sheet("Price Change Request").active = True Then
MsgBox "hello"
End if
End Sub

How do I trigger this sub routine or is there an "OnOpen" event that I can
attach my code to?

Graeme.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Is there an "OnOpen" event for Excel

If you name the macro Auto_Open, it will execute whenever Excel
is opened by the user (it will not run if the workbook is opened
via VBA). If you use the Workbook_Open macro in the ThisWorkbook
module, that procedure will run whenever the file opens, either
by the user or by VBA.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"Jurrasicway" wrote in
message
...
Hi,
I wish to display a message box when a user opens the
spreadsheet. How do I
make my message box code run? I have tried the following but it
does not seem
to work:

Sub DisplayMessageBox()
If Sheet("Price Change Request").active = True Then
MsgBox "hello"
End if
End Sub

How do I trigger this sub routine or is there an "OnOpen" event
that I can
attach my code to?

Graeme.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 644
Default Is there an "OnOpen" event for Excel

In the VB editor double-click the "ThisWorkbook" on the properties
window, then in the code window select workbook in the left combobox
and open in the right combobox. put your MsgBox code in there.

HTH

Die_Another_Day

Jurrasicway wrote:
Hi,
I wish to display a message box when a user opens the spreadsheet. How do I
make my message box code run? I have tried the following but it does not seem
to work:

Sub DisplayMessageBox()
If Sheet("Price Change Request").active = True Then
MsgBox "hello"
End if
End Sub

How do I trigger this sub routine or is there an "OnOpen" event that I can
attach my code to?

Graeme.


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 84
Default Is there an "OnOpen" event for Excel

Yep, use Workbook_Open. In the VBE Project Browser, find your project, open
the folder, "Microsoft Excel Objects" and double-click on the "ThisWorkbook"
item. Select "Workbook" from the "(General)" drop list, and select "Open"
from the "(Declarations)" drop list. Put your code in the Workbook_Open sub.

"Jurrasicway" wrote:

Hi,
I wish to display a message box when a user opens the spreadsheet. How do I
make my message box code run? I have tried the following but it does not seem
to work:

Sub DisplayMessageBox()
If Sheet("Price Change Request").active = True Then
MsgBox "hello"
End if
End Sub

How do I trigger this sub routine or is there an "OnOpen" event that I can
attach my code to?

Graeme.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 510
Default Is there an "OnOpen" event for Excel

Hi

There is an Open event for Excel workbook. Open VBA editor, and in VBA
Project window, right-click on ThisWorkbook object, and select View Code.
Then select Workbook in left dropdown at top of code window - Open event is
the one automatically created after that.


--
Arvi Laanemets
( My real mail address: arvi.laanemets<attarkon.ee )



"Jurrasicway" wrote in message
...
Hi,
I wish to display a message box when a user opens the spreadsheet. How do
I
make my message box code run? I have tried the following but it does not
seem
to work:

Sub DisplayMessageBox()
If Sheet("Price Change Request").active = True Then
MsgBox "hello"
End if
End Sub

How do I trigger this sub routine or is there an "OnOpen" event that I can
attach my code to?

Graeme.





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 133
Default Is there an "OnOpen" event for Excel

If you want to display the message when a sheet is activated, put your
code in the Sheet Object Activate sub. i.e.

Private Sub Worksheet_Activate() ' Built in subroutine
MsgBox "hello"
End Sub

SteveM

Jurrasicway wrote:
Hi,
I wish to display a message box when a user opens the spreadsheet. How do I
make my message box code run? I have tried the following but it does not seem
to work:

Sub DisplayMessageBox()
If Sheet("Price Change Request").active = True Then
MsgBox "hello"
End if
End Sub

How do I trigger this sub routine or is there an "OnOpen" event that I can
attach my code to?

Graeme.


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
Excel Equivalent of Access "Load" Event? LarryP Excel Discussion (Misc queries) 2 April 7th 10 08:44 PM
Excel - Golf - how to display "-2" as "2 Under" or "4"as "+4" or "4 Over" in a calculation cell Steve Kay Excel Discussion (Misc queries) 2 August 8th 08 01:54 AM
Count occurences of "1"/"0" (or"TRUE"/"FALSE") in a row w. conditions in the next BCB New Users to Excel 7 May 13th 06 10:02 PM
How so I make a "Worksheet_Change Event" to show cell changes in Excel? susiecmore Excel Programming 1 April 26th 06 06:41 PM
OnOpen event Aaron Excel Programming 1 October 28th 04 02:35 PM


All times are GMT +1. The time now is 04:49 AM.

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

About Us

"It's about Microsoft Excel"