Please help with userform command button to printout worksheet

leoh48763

Board Regular
Joined
Apr 2, 2005
Messages
64
Good morning all. Something that I thought would be rather simple has turned out to give me alot of problems. All Im trying to do is print a worksheet from inside the userform. Excel shows it is sent to the printer but does not print. Then it hangs up, shuts down and recovers my file but will not print. The code is below. Is it something Im doing???. Ive checked both of my books for a solution. Please help..

If UserForm1.CheckBox1.Value = False Then _
Exit Sub
If UserForm1.CheckBox1.Value = True Then _
Worksheets("FUNT").Range("A29").Value = "Face"
Worksheets("FUNT").Range("A30").Value = "UP"
Worksheets("FUNT").Range("A33").Value = UserForm1.DTPicker1.Value

If UserForm1.CheckBox4.Value = True Then _
Worksheets("FUNT").Range("A31").Value = ("8'")
Worksheets("funt").Visible = True
Worksheets("FUNT").PrintOut Copies:=1, Collate:=True
Worksheets("funt").Visible = xlVeryHidden
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
I have tested your code as is and found that it works OK on my machine.

Try my re-written version below. You have not shown how it runs. I did it from a button on the form.

Try it without hiding the worksheet, sometimes the code runs too fast and gets to a line too soon for things to happen (my printer is not networked)

Your code is unformatted/uncommented in the message. It was just clear enough to get a look. much more and no one would try to read it.;)

Code:
Private Sub CommandButton1_Click()
    If UserForm1.CheckBox1.Value = False Then
        Exit Sub
    Else
        Worksheets("FUNT").Range("A29").Value = "Face"
        Worksheets("FUNT").Range("A30").Value = "UP"
        Worksheets("FUNT").Range("A33").Value = UserForm1.DTPicker1.Value
    End If
    '-----------------------------------------------------------------------------
    If UserForm1.CheckBox4.Value = True Then
        Worksheets("FUNT").Range("A31").Value = ("8'")
        Worksheets("funt").Visible = True
        Worksheets("FUNT").PrintOut Copies:=1, Collate:=True
        '-------------------------------------------------------------
        '- Try without this line *******************************
        'Worksheets("funt").Visible = xlVeryHidden '? ****** ?????????
        '-------------------------------------------------------------
    End If
    '-----------------------------------------------------------------------------
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,222
Messages
6,123,706
Members
449,118
Latest member
MichealRed

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