Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 60
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Commandbutton caption change peter.thompson[_6_] Excel Programming 6 December 22nd 05 06:29 AM
Caption disappears from CommandButton. Ed Excel Programming 0 April 19th 05 09:23 PM
CommandButton caption title Paul Excel Programming 1 August 5th 04 11:38 PM
Change CommandButton Caption Claude Excel Programming 4 July 16th 04 04:18 PM
CommandButton.Caption Bob Phillips[_5_] Excel Programming 0 September 8th 03 08:15 AM


All times are GMT +1. The time now is 02:28 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"