Hi Hans
I thought before trying to use
On Error Resume Next
I thought I might check things a little further. I believe I was able to narrow it down a little bit closer to the problem. It seems that when I have completed the report and I use this code to print
Code: Select all
Private Sub CommandButton2_Click()
Dim wssheet As Worksheet
Application.ScreenUpdating = False
For Each wssheet In ActiveWorkbook.Worksheets
Next wssheet
If CheckBox1.Value And Sheets("Cover Page").Visible = xlSheetVisible Then _
Sheets("Cover Page").Select Replace:=True
If CheckBox2.Value And Sheets("Client Information").Visible = xlSheetVisible Then _
Sheets("Client Information").Select Replace:=False
If CheckBox3.Value And Sheets("Utilities").Visible = xlSheetVisible Then _
Sheets("Utilities").Select Replace:=False
ActiveWindow.SelectedSheets.PrintOut
For Each wssheet In ActiveWorkbook.Worksheets
Next wssheet
Application.ScreenUpdating = True
End Sub
I would then close and save workbook. The problem then seems to occur.
The way I found it was I kept going through one piece of code at a time, then close and save, until I found the culprit.
As I mentioned before if select a sheet and close and save from there every things good.
So what I thought was, add some additional code to the print code that would select a sheet.
so I added
Code: Select all
Unload Me
Unload UserForm4
Worksheets("Cover Page").Select
ActiveSheet.Range("D7").Select
ActiveSheet.Protect DrawingObjects:=False, Contents:=True, Scenarios:=True, _
Password:="", UserInterfaceOnly:=True
ActiveWorkbook.Protect Password:="", Structure:=True, Windows:=True
right after
Application.ScreenUpdating = True
I'm not sure if this is the right approach or not but it seems to work