LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Creating Name for a Command Button

Hi Alan,

I guess you are looking for -

Set ThisCommandButton = Me.OLEObjects(ThisButtonName)

Perhaps you might also want to declare the object variable,
Dim ThisCommandButton As OLEObject

I assume you have a reason for declaring your variables at module level.

Regards,
Peter T

"Alan Douglas" wrote in message
...
I want to create a piece of code that can refer to a specified command
button number

I have tried approaches like the following intiated by clicking Commmand
Button 4:

Dim ThisButtonNo As String
Dim ThisButtonName as string
Dim ThisCommandButton As Object

Private Sub CommandButton4_Click()
ThisButtonNo = "2"
ThisButtonName = "CommandButton" & ThisButtonNo
Set ThisCommandButton = ThisButtonName
ThisCommandButton.Enabled = True
End Sub

The problem is with the CommandButton object variable not set, but I don't
know what code/variables to use to do this.

Alan




 
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
command button add another command Wanna Learn Excel Discussion (Misc queries) 5 December 7th 08 11:42 PM
Creating a Command Button on a worksheet GeorgeJ Excel Discussion (Misc queries) 0 August 1st 07 09:42 PM
Creating Command button Conditionally Todd Huttenstine[_2_] Excel Programming 2 January 17th 04 07:57 PM
Command Button vs Control Button RGibson Excel Programming 1 October 14th 03 02:24 AM
Command Button vs Form Button T K Excel Programming 4 August 26th 03 07:26 PM


All times are GMT +1. The time now is 05:29 PM.

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"