Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / July 2008

Tip: Looking for answers? Try searching our database.

Command Button Caption - VBA

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
dustinb - 31 Jul 2008 18:36 GMT
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.CommandButton.1", Link:=False _
   , DisplayAsIcon:=False, Left:=1, Top:=1, Width:=135, Height:= _
   25.5).Select

ActiveSheet.OLEObjects("CommandButton1").Object.cmdButton.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.".
JLGWhiz - 31 Jul 2008 19:00 GMT
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.".
dustinb - 31 Jul 2008 19:24 GMT
Great !!!! Thanks for the help.
>You had too much in the statement.  Try this.
>
[quoted text clipped - 6 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.".
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.