Need help with which event triggers to use with my codeI

moradisndat

New Member
Joined
Feb 19, 2021
Messages
15
Office Version
  1. 2007
Platform
  1. Windows
I have a user-form menu with command buttons to navigate or perform action. The problem I have is with print preview. Its like a modal window or something-I don't know what to call it. Once the print preview button on my form is clicked, everything is disabled except for the application toolbar. I'm looking for an event trigger right after the user exits print preview because I need to make changes to user form and hide a label but I dont know where to put the code.

Any help or suggestions are greatly appreciated.
Thanks
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
Change the ShowModal property of the Userform to "False"

1628854217099.png
 
Upvote 0
Change the ShowModal property of the Userform to "False"

View attachment 44781
thank you for the reply. Yes the property is set to false. The problem isnt my form. The button works fine. When the sheet goes into print preview, the application code takes over I guess and the only way to exit is by using the application toolbar. That is fine, but I need an event to run some code at that point. what would be perfect would be "on print preview exit" but there isnt anything like that. The only "change" to sheet is that it goes from print preview to normal view. And I can't use "on activate" because i dont want the code to run everytime the sheet is activated, only when it leaves print preview.
 
Upvote 0
but I need an event to run some code

I don't know how you got the call to printpreview.
It would help if you put your code here.

But if you have something like this, when you close the printpreview, the control returns to the userform code and you can execute the code you need.

VBA Code:
Private Sub CommandButton1_Click()
  ActiveSheet.PrintPreview
  MsgBox "I am back"
  'here you can put your code
End Sub
 
Upvote 0
Solution
I don't know how you got the call to printpreview.
It would help if you put your code here.

But if you have something like this, when you close the printpreview, the control returns to the userform code and you can execute the code you need.

VBA Code:
Private Sub CommandButton1_Click()
  ActiveSheet.PrintPreview
  MsgBox "I am back"
  'here you can put your code
End Sub
Thank you. I used the "ActiveSheet.PrintPreview" code on the command button but I didn't realize the control would return to it when the print preview window is closed. Solves the problem. Thanks again.
 
Upvote 0
Thank you. I used the "ActiveSheet.PrintPreview" code on the command button but I didn't realize the control would return to it when the print preview window is closed. Solves the problem. Thanks again.
You marked your answer as a solution, you must mark the answer that really helped you as a solution.

Glad to help you. Thanks for the feedback.
 
Upvote 0
I switched the marked solution with the actual answer post.

@moradisndat - in your future questions, please mark the post as the solution that answered your question to help future readers. If you answered your own question then you can mark your post as the solution.
 
Upvote 0
Power Query:
You marked your answer as a solution, you must mark the answer that really helped you as a solution.

Glad to help you. Thanks for the feedback.
Oh i didnt realize it. guess i got mixed up. Sorry about that. I've actually replied to myself in gmail before. ?
 
Upvote 0

Forum statistics

Threads
1,214,985
Messages
6,122,602
Members
449,089
Latest member
Motoracer88

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top