?
Solved

VBA-Problem: dynamic gerneration of Buttons in Excel - set the caption?

Posted on 2003-03-19
3
Medium Priority
?
373 Views
Last Modified: 2013-12-26
I want to generate buttons in Excel dynamically.

I did this using:

  Set bu = ActiveWorkbook.ActiveSheet.Shapes.AddFormControl(xlButtonControl, Left:=150, Top:=30, Width:=100, Height:=12)
  bu.Name = "Button1"
  bu.OnAction = "run1"

But I found no property or method to set the caption of the button. There is always a "Standard Caption" (Schaltfäche ## in German version)

Please don't give me solutions with using OLEObjects.Add("Forms.CommandButton.1"),...


0
Comment
Question by:wbrunner
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 3

Expert Comment

by:kokoloko
ID: 8167678
Try this:
  bu.DrawingObject.Caption = "kokoloko"
0
 

Author Comment

by:wbrunner
ID: 8168046
Where did you find this info? In the docu the DrawingObject does not exist!
0
 
LVL 3

Accepted Solution

by:
kokoloko earned 300 total points
ID: 8169859
It's all a bit of magic...
... with a little help from the Watches Debugger Window
(During debugging, right click on your 'bu' object and select 'Add Watch')
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses
Course of the Month12 days, 13 hours left to enroll

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question