Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 270
Default Button Focus

Excel 2003
I have a button from the Forms toolbar named "Register".
The button is on the sheet - not on a form.

I would like to set the focus to this button in the following code

Code
Sub Worksheet_Change(ByVal Target As Range)

If Range("A1").Value < "" Then
Buttons("Register").SetFocus
Else
........... other code..........
End if

End Sub
<<Code

Obviously this does not work - it produces the following error:-

"Run-Time error '438':
Object doesn't support this property or method"

Any help appreciated

Sandy
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Button Focus


Controls from the Forms menu do not have a SetFocus method. You could use
'Select' but I suspect you don't want to do that. You may want to change to
an ActiveX button, simply call the original code from its click event in the
worksheet module. You'll then be able to do -

ActiveSheet.OLEObjects("CommandButton1").Activate

Regards,
Peter T

"Sandy" wrote in message
...
Excel 2003
I have a button from the Forms toolbar named "Register".
The button is on the sheet - not on a form.

I would like to set the focus to this button in the following code

Code
Sub Worksheet_Change(ByVal Target As Range)

If Range("A1").Value < "" Then
Buttons("Register").SetFocus
Else
........... other code..........
End if

End Sub
<<Code

Obviously this does not work - it produces the following error:-

"Run-Time error '438':
Object doesn't support this property or method"

Any help appreciated

Sandy



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,049
Default Button Focus


Option Explicit

Sub Worksheet_Change(ByVal Target As Range)

If Range("A1").Value < "" Then
''Buttons("Register").SetFocus
ActiveSheet.Shapes("Register").Select
Else
'........... other code..........
End If

End Sub





"Sandy" wrote in message
...
Excel 2003
I have a button from the Forms toolbar named "Register".
The button is on the sheet - not on a form.

I would like to set the focus to this button in the following code

Code
Sub Worksheet_Change(ByVal Target As Range)

If Range("A1").Value < "" Then
Buttons("Register").SetFocus
Else
........... other code..........
End if

End Sub
<<Code

Obviously this does not work - it produces the following error:-

"Run-Time error '438':
Object doesn't support this property or method"

Any help appreciated

Sandy


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,049
Default Button Focus

Whats the point of selecting the button? Why don't you just trigger some
code with an input box ? I assume that you're "asking" the user to do
something?

"Sandy" wrote in message
...
Excel 2003
I have a button from the Forms toolbar named "Register".
The button is on the sheet - not on a form.

I would like to set the focus to this button in the following code

Code
Sub Worksheet_Change(ByVal Target As Range)

If Range("A1").Value < "" Then
Buttons("Register").SetFocus
Else
........... other code..........
End if

End Sub
<<Code

Obviously this does not work - it produces the following error:-

"Run-Time error '438':
Object doesn't support this property or method"

Any help appreciated

Sandy


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
How to Set Focus a row - Option Button Click Lisab Excel Programming 2 September 26th 07 09:50 PM
Push Button in Outlook to Change Focus to Outlook Contact List Cole Excel Programming 0 October 25th 06 11:29 PM
Option Button/Focus Problem on Worksheet Resume Next Excel Programming 4 September 20th 05 01:10 AM
Set focus on command button Derek Gadd[_2_] Excel Programming 2 February 11th 04 09:52 AM
button focus billq Excel Programming 4 November 13th 03 02:09 PM


All times are GMT +1. The time now is 03:01 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"