By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,337 Members | 2,234 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,337 IT Pros & Developers. It's quick & easy.

Caption of command button not displaying until clicked.

P: 88
I hope that this is the right forum. I'm using VB to create a report in Excel. After the report is generated I put two buttons onto the title sheet. Both are for printing a part of the report. Here is my code;

Expand|Select|Wrap|Line Numbers
  1. button1 = ApExcel.ActiveSheet.OLEObjects.Add(ClassType:="Forms.CommandButton.1", Link:=False _
  2.         , DisplayAsIcon:=False, Left:=119.25, Top:=217.5, Width:=110, Height:= _
  3.         24).Select
  4.  
  5. ApExcel.ActiveSheet.CommandButton1.Caption = "Print Summary Report"
  6.  
  7. button2 = ApExcel.ActiveSheet.OLEObjects.Add(ClassType:="Forms.CommandButton.1", Link:=False _
  8.         , DisplayAsIcon:=False, Left:=119.25, Top:=285.75, Width:=110, Height _
  9.         :=24).Select
  10.  
  11. ApExcel.ActiveSheet.CommandButton2.Caption = "Print Full Report"
  12.  
The buttons get put on the worksheet ok, and they work. The only thing is that the caption of the button does not display until the button is clicked. Instead it displays the button name. (CommandButton1, and CommandButton2), as soon as it looses focus it goes back to the button name.

This just looks really bad in the report. Any ideas what I'm doing wrong?

Thanks
Franccesca
Sep 10 '07 #1
Share this Question
Share on Google+
1 Reply


VBPhilly
P: 95
... the caption of the button does not display until the button is clicked. Instead it displays the button name ...
I don't have a solution but a suggested debug step: put a messagebox after the caption assignment. See how VBA sees the caption button.
Also, is there some kind of refresh mechanism for your form? I know there is in VB6.
Sep 10 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.