Caption of a button

D

Dr_Phil

hi, how do you change the caption of a button from VBA code. The button
is on a sheet called XS003 if that helps......

from VB it is commandbutton1.caption = "blah blah blah"

but that dosnt seem to work

any help would be appreciated....

thanx
 
H

Harald Staff

Hi

Sure it seems to work.

Private Sub CommandButton1_Click()
Sheets(1).CommandButton1.Caption = Now
End Sub

HTH. Best wishes Harald
 
D

Dr_Phil

yea that does work....but i forgot to say that when my sheet loads i
automativlly adds a command button to it.....let me xplain

i have workbook A and when the user types a file name on that sheet an
clicks open it opens that file....now when that file opens i want it t
add a button to it which will say save and close....this is to make i
easer for my staff to use as i need it to be correctly named etc etc..
hope that makes sense
 
H

Harald Staff

Dr_Phil > said:
i forgot to say that when my sheet loads it
automativlly adds a command button to it.(...)
when that file opens i want it to
add a button to it which will say save and close

It's not too clear what works and what doesn't. Please post the code that
adds the button if you have it, including the "dosnt seem to work" parts.

Best wishes Harald
 
D

Dr_Phil

hi,

right:


I have a workbook that has an open button on it with a space for a use
to enter a file name into, eg "hello". When the user clicks the butto
the workbook will add ".csv" to the file name and open it. When thi
new workbook opens, "hello.csv", i want a button to be placed on i
with the caption "Save".

I hope this makes sense
 
Top