Caption of command button not displaying until clicked.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • fperri
    New Member
    • May 2007
    • 88

    #1

    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;

    Code:
    button1 = ApExcel.ActiveSheet.OLEObjects.Add(ClassType:="Forms.CommandButton.1", Link:=False _
            , DisplayAsIcon:=False, Left:=119.25, Top:=217.5, Width:=110, Height:= _
            24).Select
    
    ApExcel.ActiveSheet.CommandButton1.Caption = "Print Summary Report"
     
    button2 = ApExcel.ActiveSheet.OLEObjects.Add(ClassType:="Forms.CommandButton.1", Link:=False _
            , DisplayAsIcon:=False, Left:=119.25, Top:=285.75, Width:=110, Height _
            :=24).Select
    
    ApExcel.ActiveSheet.CommandButton2.Caption = "Print Full Report"
    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
  • VBPhilly
    New Member
    • Aug 2007
    • 95

    #2
    Originally posted by fperri
    ... 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.
    Last edited by Killer42; Sep 11 '07, 02:43 AM. Reason: Reduced excessive quote block

    Comment

    Working...