Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.misc
|
|||
|
|||
close workbook without closing excel and stop recursive function
I earlier implemented a feature in one macro to allow blinking text.
The code is as follows: Sub StartBlink() Range("A1").Font.ColorIndex = RandomNumber(2, 56) 'Pauses it by a second RunWhen = Now + TimeSerial(0, 0, 1) 'Restarts the function Application.OnTime RunWhen, "StartBlink", , True End Sub Sub StopBlink() Range("A1").Font.ColorIndex = xlColorIndexAutomatic 'Breaks the StartBlink function from continuing to run Application.OnTime RunWhen, "StartBlink", , False End Sub I have the following code that calls the functions upon workbook open and close in the This Workbook sheet: Private Sub Workbook_Open() 'Opens the StartBlink function when the file opens StartBlink End Sub Private Sub Workbook_BeforeClose(Cancel As Boolean) 'Stops the Stopblink function to prevent error message upon exit StopBlink End Sub This seemed to work great until I added a button to save and close and prompt users if they wanted to exit excel entirely or just close the workbook: Private Sub CommandButton2_Click() 'Changes Caption back to "Stop Blink" for next time CommandButton1.Caption = "Stop Blink" 'Saves Workbook ActiveWorkbook.Save 'Prompts if you want to close Excel entirely or just close the current window you are in If MsgBox("Do you want to exit Excel?", vbYesNo, "Exit Microsoft Excel") = vbYes Then Application.Quit Else Workbooks("Wedding List.xls").Close End If End Sub If they choose to not exit excel, it appears to close the workbook. However, it just reopens the workbook a second later when it apparently calls the StartBlink function again. Anyway to modify some of this code to allow users to close the workbook for good without closing any other excel windows? Thanks in advance! |
#2
Posted to microsoft.public.excel.misc
|
|||
|
|||
close workbook without closing excel and stop recursive function
"chris" wrote in message
ps.com... <SNIP some VBA code However, it just reopens the workbook a second later when it apparently calls the StartBlink function again. Anyway to modify some of this code to allow users to close the workbook for good without closing any other excel windows? Thanks in advance! Do you happen to have the code in the workbook you close? /Dann |
#3
Posted to microsoft.public.excel.misc
|
|||
|
|||
close workbook without closing excel and stop recursive function
Yeah. The actual functions are in the modules associated with the
workbook and the function that starts and stops it is in the This Workbook sheet associated with this project. Why? Dann Pedersen wrote: "chris" wrote in message ps.com... <SNIP some VBA code However, it just reopens the workbook a second later when it apparently calls the StartBlink function again. Anyway to modify some of this code to allow users to close the workbook for good without closing any other excel windows? Thanks in advance! Do you happen to have the code in the workbook you close? /Dann |
#4
Posted to microsoft.public.excel.misc
|
|||
|
|||
close workbook without closing excel and stop recursive function
I fixed the problem by moving the stop and start function from Private
in this workbook to public in the module. Not sure why that fixes it, but seems to work now. chris wrote: Yeah. The actual functions are in the modules associated with the workbook and the function that starts and stops it is in the This Workbook sheet associated with this project. Why? Dann Pedersen wrote: "chris" wrote in message ps.com... <SNIP some VBA code However, it just reopens the workbook a second later when it apparently calls the StartBlink function again. Anyway to modify some of this code to allow users to close the workbook for good without closing any other excel windows? Thanks in advance! Do you happen to have the code in the workbook you close? /Dann |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Excel 2003 FAILS, but Excel 2000 SUCCEEDS ??? | Excel Discussion (Misc queries) | |||
How to stop Excel remembering/loading macro from previously opened Workbook | Excel Discussion (Misc queries) | |||
How do I stop Excel from closing the open file each time I open a. | Setting up and Configuration of Excel | |||
Stubborn toolbars in Excel | Excel Discussion (Misc queries) | |||
How do I stop the autopaste function in Excel? | Excel Worksheet Functions |