467,927 Members | 1,987 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 467,927 developers. It's quick & easy.

Caption of command button not displaying until clicked.

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
  • viewed: 1805
Share:
1 Reply
VBPhilly
... 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.

Similar topics

2 posts views Thread by mksql | last post: by
9 posts views Thread by Randall Sell | last post: by
2 posts views Thread by Colin | last post: by
3 posts views Thread by Paul Hodgson | last post: by
1 post views Thread by Peter Rilling | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.