Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Msgbox freezing in beforeprint module
This has been driving me crazy!
I have msgbox code validating data in both my before_print and before_save modules; the code is identical in both (except for some slight text changes in the message boxes). When I save the document the message box pops up and closes correctly; when I print/print preview the message box pops up, allows you to click the "OK" button, but remains on the screen and doesn't allow you to close it (either with the red x button or by clicking OK again). The only way I've figured to get around it is to manually run another macro that plugs in dummy data where I've had the code validate. Below is one of the msgbox sections, as I said before both the before_save and before_print modules are identical. The idea is if a checkbox is selected (in this case, biotaarrowcheck1) then data must be entered in at least one of the cells in the range (h37:n37). If data is not entered, the message box pops up and cancels the save/print, cancels the procedure, and goes away. It would be nice if it could select a range at the end (.range("h37").select), but when I added that to the procedure beforesave didn't work at all. Thank you for all your help, I've been wrestling with this for a while. With worksheets("human health csm") 'Tests Ingestion of Wild Foods row If .BiotaArrowCheck1.value = True Then If Application.CountA(.range("h37:n37")) < 1 Then MsgBox ("Please enter the current and/or future receptors in the Ingestion of Wild Foods row." & vbNewLine & "Your action has been cancelled.") Cancel = True End End If End If End With |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Msgbox freezing in beforeprint module
I couldn't duplicate this behaviour (in Excel XP), so I can't be sure
what is going on. However, it sounds like it MIGHT be a problem with screenupdating being turned off by some other event procedure - that "End" statement might prevent screenupdating being turned on again. A couple of things to try: 1. replace END with EXIT SUB 2. if that doesn't do it, just before the exit sub put in msgbox application.screenupdating just to see if the screenupdating is off or not 3. add a break point and then step through this procedure to see if any other code is being invoked (e.g. by some other application event) David Sauder |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Msgbox freezing in beforeprint module
David,
Thank you so much for your reply! I didn't even think about the application.screenupdating part, I did indeed have it set to false at the beginning of the procedure, and the END statement wasn't resetting it to true. I added application.screeupdating = true just before the END statement and it did the trick. Again, thank you! -Hannah "David Sauder" wrote: I couldn't duplicate this behaviour (in Excel XP), so I can't be sure what is going on. However, it sounds like it MIGHT be a problem with screenupdating being turned off by some other event procedure - that "End" statement might prevent screenupdating being turned on again. A couple of things to try: 1. replace END with EXIT SUB 2. if that doesn't do it, just before the exit sub put in msgbox application.screenupdating just to see if the screenupdating is off or not 3. add a break point and then step through this procedure to see if any other code is being invoked (e.g. by some other application event) David Sauder |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
BeforePrint | Excel Programming | |||
BeforePrint help | Excel Programming | |||
BeforePrint Add In | Excel Programming | |||
ADO 2.7 & ADO 2.8 beforeprint | Excel Programming | |||
Help with BeforePrint | Excel Programming |