PDA

View Full Version : [SOLVED] MS Project 2003 Close Print Preview



mallarym
09-01-2007, 09:01 AM
I am using an userForm to perform various tasks (applying filters, sorts, etc)

I have a command button to take the current view and show the Print Preview



Private Sub cmdPrint_Click ()
FilePrintPreview
End Sub


However, I get not figure out hold to close the print preview through VBA. I have tried closing the active window, ViewApply to another view, none work.

I would appreciate any help. Thanks

AM

lucas
09-01-2007, 09:14 AM
What are you looking for a timer?

lucas
09-01-2007, 09:25 AM
Might take a look at this. It's for Excel but I think you can apply it to MSProject. I don't have project so that's about all I can do to help you.
http://www.xcelfiles.com/API_02.html

Scroll to the bottom of the page and Ivan shows how to incorporate the timer into a 5 second printpreview.

mallarym
09-02-2007, 01:59 AM
I might use that timer for something else I am working on.

For this, I really just want the user to push a button and have the Print Preview close.

I am using a userForm, so for the user to use the normal CLOSE button, they have to close the userform which I do not want.

I have tried recording a macro, but it only shows the open and no code for the close.

As I said, closing the activewindow, etc has not worked.

lucas
09-02-2007, 09:50 AM
So If I understand...you are opening a printpreview with the userform still open and so it is in front of your preview?

Why not just close or hide the userform while the preview is shown and when they close the preview have your userform come back into view?

mallarym
09-02-2007, 09:14 PM
That is doable. How do you suggest calling it back up? I am not finding anything in VBA for project that recognizes the event of print preview.

lucas
09-03-2007, 09:29 AM
This works for me in excel....

Private Sub CommandButton1_Click()
Unload UserForm1
ActiveWindow.SelectedSheets.PrintPreview
UserForm1.Show
End Sub
Following that train of thought this might work for you in Project if the code you posted in the beginning of this thread brings up printpreview for you.

Private Sub cmdPrint_Click()
Unload UserForm1
FilePrintPreview
UserForm1.Show
End Sub
You will need to change the userform1 to refect your actual userform's name.

mallarym
09-05-2007, 06:45 AM
That didn't work, but I figured out a work around

I made a custom toolbar with a button to call the userform back up. So from the print preview, the user closes the print preview and then click the button to bring the userForm menu back up.