Home |
Search |
Today's Posts |
#7
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi again,
I am not really full bottle on using OLEObjects and while the code I gave you works, the syntax is not complete. If you include everything then it works with objects assigned to variables as per the following example:- Sub Test_Caption_2() Dim ws As Worksheet Set ws = ThisWorkbook.Worksheets("Sheet1") ws.OLEObjects("CommandButton1").Object.Caption = "run me" End Sub Check out the following Microsoft web site for more information on using ActiveX controls (Worth adding to your favourites):- http://msdn2.microsoft.com/en-us/lib...ffice.10).aspx -- Regards, OssieMac " wrote: That worked thanks It was the Sheets("Sheet1") that was missing. I did try this and it didnt work: Set wks = ThisWorkbook.Worksheets("sheet1") wks.makebusy.caption="start" Why is that? Once again, thanks for the help and on to the next challenge. :) Cheers. On Nov 21, 5:11 am, OssieMac wrote: Hi again, If created under the Control Toolbox it is actually an ActiveX control. You do see the dialog box if the Design mode is turned on when you right click it. With a Forms button, you don't use Design Mode and you see the dialog box simply by right clicking on the button. Anyway example of code the code is:- Sheets("Sheet1").CommandButton1.Caption = "Start" You said that you gave it the name 'makebusy'. Did you mean the Name or the Caption? They are different. In the above code CommandButton1 is the name. You can see both name and caption in Properties. If 'makebusy' is the name then your code will be:- Sheets("Sheet1").makebusy.Caption = "Start" Of course you will need to edit the sheet name to suit your sheet name. Or if it is on a userform then:- UserForm1.makebusy.Caption = "Start" Again you will need to edit the userform name to suit your userform. Hope this helps. Feel free to get back to me if you have any further problems with it. -- Regards, OssieMac " wrote: Hi, Thanks for all the help. It is a Forms button. I used the control toolbox to create the button adn I do get all those option when right clicking on it in design mode. Under properties I gave it the name 'makebusy'. Thanks again for all the help. On Nov 21, 1:05 am, OssieMac wrote: Hi, There are two types of buttons. Need to know what type. One is created from the Forms toolbar and the other is and ActiveX control created from the Control Toolbox toolbar. (Both look alike) Right click on the button. If you get a dialog box with a number of options including Cut, Copy Paste etc then it is a Forms button. If nothing happens or only a dotted line around just inside the perimeter, it is an ActiveX control. Let me know what type of button you have and I'll provide sample code and instructions on how to identify the button name for the code. -- Regards, OssieMac " wrote: I just want to add that the button is not created with Auto_open sub. It is already in the spreadsheet. I just want to make sure that the caption is changed to "start" Thanks |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Change caption of a button | Excel Worksheet Functions | |||
Copy button caption | Excel Programming | |||
Toggle Button Caption | Excel Programming | |||
How to change Button Caption? | Excel Programming | |||
Caption of a button | Excel Programming |