Print preview command button, NON visible workbook

  • After all,


    I have made my workbook not visible so the user will only be able to use userforms BUT i want to have a print preview OR print button that will print off a range on a worksheet.

    STUCK!

  • You could add a command button on the userform and change the caption to PRINT. In the code module for the command button insert the code to print the range when the command button is clicked.

    You can say "THANK YOU" for help received by clicking the "Like" icon in the bottom right corner of the helper's post.
    Practice makes perfect. I am very far from perfect so I'm still practising.

  • You could add a command button on the userform and change the caption to PRINT. In the code module for the command button insert the code to print the range when the command button is clicked.

    Yep already have a cmdbutton on the userform with the code to print preview BUT when the preview comes up excel hangs and i have to shut via task manger so i was thinking this has something to do with the workbook being hidden?

  • I don't know what is causing the problem. Maybe you can try adding code to make the workbook visible, print the range and then hide it again.

    You can say "THANK YOU" for help received by clicking the "Like" icon in the bottom right corner of the helper's post.
    Practice makes perfect. I am very far from perfect so I'm still practising.

  • I don't know what is causing the problem. Maybe you can try adding code to make the workbook visible, print the range and then hide it again.

    I did try this but being very new to VBA im not to sure if i got it write and upon searching the net dint find a great deal on it

  • I don't know if I can offer a solution, but without seeing your workbook it is difficult to see what is happening.

    You can say "THANK YOU" for help received by clicking the "Like" icon in the bottom right corner of the helper's post.
    Practice makes perfect. I am very far from perfect so I'm still practising.

  • theres quite alot of my company data in the workbook now so i can share really, thanks anyway ill just have to keep trying different things until i hit lucky

  • You could delete all the confidential data and include only the range you want to print replacing the data with dummy information. Include the macros and userforms you are currently using.

    You can say "THANK YOU" for help received by clicking the "Like" icon in the bottom right corner of the helper's post.
    Practice makes perfect. I am very far from perfect so I'm still practising.

  • You need to hide the userform first, that will prevent the "hanging"


    Code
    Private Sub CommandButton1_Click()
    Me.Hide
    ActiveSheet.PrintPreview
    Me.Show
    End Sub
  • You need to hide the userform first, that will prevent the "hanging"


    Code
    Private Sub CommandButton1_Click()
    Me.Hide
    ActiveSheet.PrintPreview
    Me.Show
    End Sub

    Thanks Roy

    That didnt work unfortunalty, im going to post the sheet up

  • Try:

    Code
    Private Sub CommandButton7_Click()
        Application.Visible = True
        Unload UserForm1
        Sheets("PurchaseOrder").Range("PurchaseOrder").PrintPreview
        Application.Visible = False
        UserForm1.Show
    End Sub

    You can say "THANK YOU" for help received by clicking the "Like" icon in the bottom right corner of the helper's post.
    Practice makes perfect. I am very far from perfect so I'm still practising.

  • Try:

    Code
    Private Sub CommandButton7_Click()
        Application.Visible = True
        Unload UserForm1
        Sheets("PurchaseOrder").Range("PurchaseOrder").PrintPreview
        Application.Visible = False
        UserForm1.Show
    End Sub

    That works perfect thank you!!

  • You are very welcome. :)

    You can say "THANK YOU" for help received by clicking the "Like" icon in the bottom right corner of the helper's post.
    Practice makes perfect. I am very far from perfect so I'm still practising.

  • Basically my code was to tell you how to use PrintPreview with a UserForm and will work. You simply need to make the application visible, as you would do if you use PrintPreview without a userform and make the application hidden.

  • In a previous post you said that you already have an email macro. Can you post that code?

    You can say "THANK YOU" for help received by clicking the "Like" icon in the bottom right corner of the helper's post.
    Practice makes perfect. I am very far from perfect so I'm still practising.

  • In a previous post you said that you already have an email macro. Can you post that code?

    It in the sheet posted but ive been using the code in a module and using a button on the tabs see module 5

  • Try:

    Code
    Private Sub CommandButton7_Click()
        Application.Visible = True
        Unload UserForm1
        Sheets("PurchaseOrder").Range("PurchaseOrder").PrintPreview
        Call AutoEmail
        Application.Visible = False
        UserForm1.Show
    End Sub

    You can say "THANK YOU" for help received by clicking the "Like" icon in the bottom right corner of the helper's post.
    Practice makes perfect. I am very far from perfect so I'm still practising.

  • Try:

    Code
    Private Sub CommandButton7_Click()
        Application.Visible = True
        Unload UserForm1
        Sheets("PurchaseOrder").Range("PurchaseOrder").PrintPreview
        Call AutoEmail
        Application.Visible = False
        UserForm1.Show
    End Sub

    Cheers Mumps works lovely ill get the hang of this soon

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!