Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

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

Posted on 2003-03-19
3
Medium Priority
?
383 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
  • 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

[Webinar] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

Question has a verified solution.

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

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

581 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