Google Answers Logo
View Question
 
Q: Excel VBA commandbutton manipulations ( No Answer,   2 Comments )
Question  
Subject: Excel VBA commandbutton manipulations
Category: Computers > Software
Asked by: astrokoala1-ga
List Price: $4.00
Posted: 18 Aug 2005 12:47 PDT
Expires: 18 Aug 2005 20:30 PDT
Question ID: 557379
Hi,
There is a command button on the Excel worksheet that I am trying to
modify or get rid of.  In the MS VB editor, in "sheet 1", the code
reads:
Private Sub CommandButton1_Click()

Call RunCalcs

End Sub

However, this code does not specify the property of the commandbutton
that I see on the Excel worksheet itself.  (ie. color, dimension,
captions on it)  If I delete it, the button is still there.
Now, I placed the following code as an experiment to add another button:
Set Newbutton=sheet1.OLEObjects.Add("Forms.CommandButton.1")
With NewButton
.left=4
.Top=4
.Width=100
.Height=24
.Object.Caption="123"
End With

and the a second button appears on the worksheet with correct
dimension/caption etc.  But when I delete the code I just wrote and
re-run the code,  the button remains! This is probably very simple but
I am new at VBA and ActiveX...  What's going on?
Answer  
There is no answer at this time.

Comments  
Subject: Re: Excel VBA commandbutton manipulations
From: myexpertsonline-ga on 18 Aug 2005 20:04 PDT
 
Buttons aren't (usually) removed "according" to the code, though it
looks like you DID create one using code.

A command button CAN be removed by right-clicking it or by using the
Drawing selector tool on the Drawing toolbar.

References:
This one is kind of the opposite of what you want to do, but does
explain how it was likely done in the first place:
http://www.officearticles.com/misc/methods_to_run_a_macro_in_microsoft_office_applications.htm

Drawing tools and the Drawing toolbar:
http://www.officearticles.com/misc/drawing_tools_in_microsoft_office.htm
Subject: Re: Excel VBA commandbutton manipulations
From: astrokoala1-ga on 18 Aug 2005 20:29 PDT
 
Hmm. For some reason I can edit it on my laptop but not in my
office... Anyhow, it seems to be working... thanks for the response.

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy