Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
CommandButton Caption Anomily
I did get it to error on me this time, it seems to have something to do with
the save process, if you make your own save routine and box it should get around this, I just made it save automatically and it was fine, but you may not want to save every time. -- -John Northwest11 Please rate when your question is answered to help us and others know what is helpful. "mickey" wrote: I posted this earlier with sample code. One response said they were not able to duplicate the problem. Have since tested only the sample code and I did duplicate the problem. PROBLEM: Command Button caption changes unexpectedly during exit. Here's more specific sample code: Insert a CommandButton anywhere in Sheet1, Named CM1, with Caption = "On" In Sheet1 insert the followig code: Private Sub CM1_Click() If CM1.Caption = "On" Then SubOn Else SubOff End If End Sub In Module1 Insert: Sub SubOn() Sheets("Sheet1").CM1.Caption = "Off": MsgBox "CM1.Caption = " & Sheets("Sheet1").CM1.Caption End Sub Sub SubOff() Sheets("Sheet1").CM1.Caption = "On": MsgBox "CM1.Caption = " & Sheets("Sheet1").CM1.Caption End Sub In This Workbook insert: Private Sub Workbook_BeforeClose(Cancel As Boolean) SubOff End Sub Follow these steps: Click on the Command Button, changing the caption to "Off" - MsgBox will confirm caption as "Off" - click Ok Click on "X" application close - caption will change to "On" - MsgBox will confirm caption as "On" - click Ok - CAPTION UNEXPECTEDLY REVERTS BACK TO "Off". Click "Cancel" - Caption changes back to "On". Question: Why did the caption revert momentarily back to "Off" after completing the "BeforeClose" event? Note: if you click on "Yes" instead of "Cancel" the application is saved while displaying "Off", however when the sheet is restarted the Command Button correctly displays "On", which confirms that the caption was indeed changed to "On" at exit, even though it momentarily displayed "Off". Does anyone else get this result? |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Commandbutton caption change | Excel Programming | |||
Caption disappears from CommandButton. | Excel Programming | |||
CommandButton caption title | Excel Programming | |||
Change CommandButton Caption | Excel Programming | |||
CommandButton.Caption | Excel Programming |