Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Command Button Caption - VBA

I have a spreadsheet that goes through some data and organizes it into two
other sheets within the same workbook. The original sheet is left as is
because it contains more detail than I have pulled out into the two new
sheets. I am trying to build some buttons into the code and can't figure out
why I can't change the caption on the buttons. I have made on click events
that will correspond to names that I will assign to the buttons. The names
part works and the buttons function but the caption still reads
CommandButton1. I have tried several versions of the below

Workbooks("WCM Macro.xls").Activate
Worksheets("Unformatted Report").Activate
Range("A1").Select

Selection.EntireRow.Insert ' Moves the data down a couple of lines so the
button is not over top of text.
Selection.EntireRow.Insert

ActiveSheet.OLEObjects.Add(ClassType:="Forms.Comma ndButton.1", Link:=False _
, DisplayAsIcon:=False, Left:=1, Top:=1, Width:=135, Height:= _
25.5).Select

ActiveSheet.OLEObjects("CommandButton1").Object.cm dButton.Caption = "Track
Selected Cell"

With ActiveSheet.Shapes("CommandButton1")
.Name = "cmdTrackShipment"
.Caption = "Track Selected Cell"
End With


Also have tried the below for caption outside of the with statement, after
commenting out the current caption line.

ActiveSheet.Shapes("CommandButton1").Caption = "Track Selected Cell" ' Before
I rename the button.

Dim cmdTrackShipment as Object ' Tried object and shape.

With cmdTrackShipment
.Caption = "Track Selected Cell"
End With

Several other options have been tried to no avail. Most of the time I get an
error that says "Object doesn't support this property or method.".

--
Message posted via http://www.officekb.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default Command Button Caption - VBA

You had too much in the statement. Try this.

ActiveSheet.OLEObjects("CommandButton1").Object _
..Caption = "Track Selected Cell"


"dustinb via OfficeKB.com" wrote:

I have a spreadsheet that goes through some data and organizes it into two
other sheets within the same workbook. The original sheet is left as is
because it contains more detail than I have pulled out into the two new
sheets. I am trying to build some buttons into the code and can't figure out
why I can't change the caption on the buttons. I have made on click events
that will correspond to names that I will assign to the buttons. The names
part works and the buttons function but the caption still reads
CommandButton1. I have tried several versions of the below

Workbooks("WCM Macro.xls").Activate
Worksheets("Unformatted Report").Activate
Range("A1").Select

Selection.EntireRow.Insert ' Moves the data down a couple of lines so the
button is not over top of text.
Selection.EntireRow.Insert

ActiveSheet.OLEObjects.Add(ClassType:="Forms.Comma ndButton.1", Link:=False _
, DisplayAsIcon:=False, Left:=1, Top:=1, Width:=135, Height:= _
25.5).Select

ActiveSheet.OLEObjects("CommandButton1").Object.cm dButton.Caption = "Track
Selected Cell"

With ActiveSheet.Shapes("CommandButton1")
.Name = "cmdTrackShipment"
.Caption = "Track Selected Cell"
End With


Also have tried the below for caption outside of the with statement, after
commenting out the current caption line.

ActiveSheet.Shapes("CommandButton1").Caption = "Track Selected Cell" ' Before
I rename the button.

Dim cmdTrackShipment as Object ' Tried object and shape.

With cmdTrackShipment
.Caption = "Track Selected Cell"
End With

Several other options have been tried to no avail. Most of the time I get an
error that says "Object doesn't support this property or method.".

--
Message posted via http://www.officekb.com


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Command Button Caption - VBA

Great !!!! Thanks for the help.
JLGWhiz wrote:
You had too much in the statement. Try this.

ActiveSheet.OLEObjects("CommandButton1").Object _
.Caption = "Track Selected Cell"

I have a spreadsheet that goes through some data and organizes it into two
other sheets within the same workbook. The original sheet is left as is

[quoted text clipped - 39 lines]
Several other options have been tried to no avail. Most of the time I get an
error that says "Object doesn't support this property or method.".


--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200807/1

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
command button caption LesHurley Excel Programming 2 November 16th 07 11:14 PM
using vba to change command button caption PaulaO Excel Programming 2 April 5th 06 07:35 PM
changing the caption of a command button JWCrosby Excel Programming 2 December 8th 05 08:09 PM
Command Button Caption Qaspec Excel Programming 1 January 27th 05 03:30 PM
Change Caption of Forms Command Button No Name Excel Programming 9 December 10th 04 07:59 AM


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