If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > PC based Database Applications > Microsoft Excel > Displaying userform uponing opening excel sheet

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-19-04, 21:37
davidkoh79 davidkoh79 is offline
Registered User
 
Join Date: Feb 2004
Posts: 21
Displaying userform uponing opening excel sheet

Hi there

I need help to display a userform when I open a particular excel sheet.(Meaning when I open the excel sheet, the userform will automatically appear with it).I can't seem to use the userform1.show command. Is there any vb code to do this coz I am using vb to write the code? pls help.thanks

david
Reply With Quote
  #2 (permalink)  
Old 02-20-04, 00:39
Smitty Smitty is offline
Registered User
 
Join Date: Dec 2003
Location: San Diego, CA
Posts: 153
Welcome to the Board!

Have you looked into a Workbook_Open event?

I.E.
Code:
Private Sub Workbook_Open
  UserForm1.Show
End Sub
That's for if you if you open a workbook, and it goes in the This Workbook module. For a sheet event, just change it to Private Sub Worksheet_Activate and put it in that sheet's module.

Hope that helps,

Smitty
Reply With Quote
  #3 (permalink)  
Old 02-20-04, 01:56
davidkoh79 davidkoh79 is offline
Registered User
 
Join Date: Feb 2004
Posts: 21
Thanks

Thanks Smitty.It would perfectly.

Can I ask u another question. For the open method, I have to include the code in that workbook. If I want to use

Private Sub Workbook_Open()

UserForm1.Show

End Sub

but if the workbook's name is another like "company". Can I change the "workbook" to "company"? And where do I put the code?

Thanks

David
Reply With Quote
  #4 (permalink)  
Old 02-20-04, 12:15
Smitty Smitty is offline
Registered User
 
Join Date: Dec 2003
Location: San Diego, CA
Posts: 153
Quote:
but if the workbook's name is another like "company". Can I change the "workbook" to "company"? And where do I put the code?
If I think I get what you're asking regarding the ThisWorkbook module. That is a static name and will be the same regardless of the workbook's actual name.

Workbook level events go into that module. I.E. Workbook_Open, Workbook_BeforeClose, Workbook_BeforePrint, etc. Event names are always the same (partially to keep you sane), so SmittysNewWorkbook_Open wouldn't do a damn thing, but Workbook_Open within Smitty's New Workbook would.

Worksheet level events go in the specific sheet modules, Worksheet_Activate, Worksheet_Deactivate. Both are Private Subs. ActiveX Control code is also stored in these modules. I.E. if you place a Control Toolbox Command Button in a worksheet, its code goes in that sheet's module.

General Subs, which can be called from anywhere in the workbook go in General Modules, which you place by going to Insert-->Module. Converse to ActiveX controls, Forms controls are assigned macros stored in General modules.

Clear as mud now?

Hope that helps,

Smitty
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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