Consulting

Results 1 to 8 of 8

Thread: MS Project 2003 Close Print Preview

  1. #1
    VBAX Regular
    Joined
    Sep 2007
    Posts
    16
    Location

    Post MS Project 2003 Close Print Preview

    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

  2. #2
    Moderator VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location
    What are you looking for a timer?
    Steve
    "Nearly all men can stand adversity, but if you want to test a man's character, give him power."
    -Abraham Lincoln

  3. #3
    Moderator VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location
    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.
    Steve
    "Nearly all men can stand adversity, but if you want to test a man's character, give him power."
    -Abraham Lincoln

  4. #4
    VBAX Regular
    Joined
    Sep 2007
    Posts
    16
    Location
    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.

  5. #5
    Moderator VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location
    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?
    Steve
    "Nearly all men can stand adversity, but if you want to test a man's character, give him power."
    -Abraham Lincoln

  6. #6
    VBAX Regular
    Joined
    Sep 2007
    Posts
    16
    Location
    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.

  7. #7
    Moderator VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location
    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.
    Steve
    "Nearly all men can stand adversity, but if you want to test a man's character, give him power."
    -Abraham Lincoln

  8. #8
    VBAX Regular
    Joined
    Sep 2007
    Posts
    16
    Location
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •