Set focus on load

  • Thread starter Thread starter andy
  • Start date Start date
A

andy

Could someone please tell me how to set the focus onto the
first object (optBtnAdd) on Sheet1 in my workbook as soon
as the file is opened? I know that in VB there is a
form_load event, but I can't seem to understand how to get
the equivelent in VB Excel, or what code to use (setfocus,
or activate, etc.). The code, and placement of it would be
most helpful. Thank you in advance

God bless you
andy
 
See Chip Pearson his page about events
http://www.cpearson.com/excel/events.htm

This event in the /thisworkbook module will run when you open the workbook

Private Sub Workbook_Open()

End Sub
Is it from the forms toolbar or controltoolbox toolbar
What you want it to do,only activate?
 
The first object was created from the visual basic
toolbar, using the control toolbox icon, and selecting
textbox. I would like the cursor go to this textbox
(focus/activate?). I have protected the sheet and have
coded so that movement (tab, and shift/tab)
forward/backward between objects is accomplished. However,
I want the cursor to be on the first object, ready for the
user to tab, or shift/tab move to the next/back when they
are ready.

Will the "Private Sub Workbook_Open()" be put on the
sheet1 code section? Would you please tell me what the
code would be?

Thank you in advance
God bless you
 
Try this Andy

Change the Sheet name and textbox name to yours

Private Sub Workbook_Open()
Sheets("Sheet1").Select
ActiveSheet.TextBox1.Activate
End Sub

You must copy this event in the Thisworkbook module

Right click on the Excel icon next to File in the menubar
And choose View code

You are now in the Thisworkbook module
Paste the Event in this place
Alt-Q to go back to Excel
Save and close the file
 
Thank you for sharing your expertise.
God bless you
-----Original Message-----
Try this Andy

Change the Sheet name and textbox name to yours

Private Sub Workbook_Open()
Sheets("Sheet1").Select
ActiveSheet.TextBox1.Activate
End Sub

You must copy this event in the Thisworkbook module

Right click on the Excel icon next to File in the menubar
And choose View code

You are now in the Thisworkbook module
Paste the Event in this place
Alt-Q to go back to Excel
Save and close the file


--
Regards Ron de Bruin
(Win XP Pro SP-1 XL2000-2003)




"andy" <[email protected]> wrote in
message news:[email protected]...
 
Back
Top