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 :thumbup: 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 :thumbup: 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 :thumbup: 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 :thumbup: 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
    1. Private Sub CommandButton1_Click()
    2. Me.Hide
    3. ActiveSheet.PrintPreview
    4. Me.Show
    5. End Sub

    Thanks Roy

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

  • Try:

    Code
    1. Private Sub CommandButton7_Click()
    2. Application.Visible = True
    3. Unload UserForm1
    4. Sheets("PurchaseOrder").Range("PurchaseOrder").PrintPreview
    5. Application.Visible = False
    6. UserForm1.Show
    7. End Sub

    You can say "THANK YOU" for help received by clicking the :thumbup: 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
    1. Private Sub CommandButton7_Click()
    2. Application.Visible = True
    3. Unload UserForm1
    4. Sheets("PurchaseOrder").Range("PurchaseOrder").PrintPreview
    5. Application.Visible = False
    6. UserForm1.Show
    7. End Sub

    That works perfect thank you!!

  • You are very welcome. :)

    You can say "THANK YOU" for help received by clicking the :thumbup: 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 :thumbup: 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
    1. Private Sub CommandButton7_Click()
    2. Application.Visible = True
    3. Unload UserForm1
    4. Sheets("PurchaseOrder").Range("PurchaseOrder").PrintPreview
    5. Call AutoEmail
    6. Application.Visible = False
    7. UserForm1.Show
    8. End Sub

    You can say "THANK YOU" for help received by clicking the :thumbup: 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
    1. Private Sub CommandButton7_Click()
    2. Application.Visible = True
    3. Unload UserForm1
    4. Sheets("PurchaseOrder").Range("PurchaseOrder").PrintPreview
    5. Call AutoEmail
    6. Application.Visible = False
    7. UserForm1.Show
    8. End Sub

    Cheers Mumps works lovely ill get the hang of this soon