Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 304
Default Command button "selected"

When you click on a command button, it seem to be selected always and when a
user does not know that and they click the enter button, it runs the macro
again. How do de-select the command button once it's clicked?

Thanks
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Command button "selected"

Disable it within the assigned macro

ActiveSheet.Buttons(Application.Caller).Enabled = False


--
---
HTH

Bob


(there's no email, no snail mail, but somewhere should be gmail in my addy)



"pgarcia" wrote in message
...
When you click on a command button, it seem to be selected always and when
a
user does not know that and they click the enter button, it runs the macro
again. How do de-select the command button once it's clicked?

Thanks



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Command button "selected"

Are these commandbuttons on a worksheet?

Are you using xl97?

If you are, then change the .takefocusonclick property to false. This was fixed
in xl2k.

If you ever use a control that doesn't have that property, you could also add a
line to the code:

activecell.activate

(It'll work with the commandbutton, too.)

pgarcia wrote:

When you click on a command button, it seem to be selected always and when a
user does not know that and they click the enter button, it runs the macro
again. How do de-select the command button once it's clicked?

Thanks


--

Dave Peterson
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 304
Default Command button "selected"

Oh, the command button takes you to another tab/sheet, so that did not work.

"Bob Phillips" wrote:

Disable it within the assigned macro

ActiveSheet.Buttons(Application.Caller).Enabled = False


--
---
HTH

Bob


(there's no email, no snail mail, but somewhere should be gmail in my addy)



"pgarcia" wrote in message
...
When you click on a command button, it seem to be selected always and when
a
user does not know that and they click the enter button, it runs the macro
again. How do de-select the command button once it's clicked?

Thanks




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 304
Default Command button "selected"

Great, that did the trick.

"Dave Peterson" wrote:

Are these commandbuttons on a worksheet?

Are you using xl97?

If you are, then change the .takefocusonclick property to false. This was fixed
in xl2k.

If you ever use a control that doesn't have that property, you could also add a
line to the code:

activecell.activate

(It'll work with the commandbutton, too.)

pgarcia wrote:

When you click on a command button, it seem to be selected always and when a
user does not know that and they click the enter button, it runs the macro
again. How do de-select the command button once it's clicked?

Thanks


--

Dave Peterson

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
Create a "cell button" to hide selected cells. Shoolin Patel Excel Worksheet Functions 12 July 30th 07 11:00 AM
Programming a "Save as..." command button within Excel DavidHawes Excel Discussion (Misc queries) 2 November 13th 06 02:48 PM
command button and the "enter" and "tab" keys dr chuck Excel Programming 10 September 11th 06 12:09 AM
set up a command button or macro for open file to "save as" Mo Excel Programming 1 June 23rd 05 12:19 AM
Making command button code "more flexible" John Wilson Excel Programming 1 August 4th 03 10:43 PM


All times are GMT +1. The time now is 08:14 AM.

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"