I'm having some trouble with the command button code below when I protect my workbook. I can protect the worksheet the button is on and lock it down so everything is tight, but as soon as I protect the workbook, I get a "Run-time error '1004': Method 'Visible' of object'_Worksheet' failed. Thank you!
Code:
Sub Print_Quote()
Dim CurVIs As Long
Dim ws As Worksheet
For Each ws In Sheets(Array("Sheet Name"))
With ws
CruVis = .Visible
If CurVIs >= 0 Then
.Visible = xlSheetVisible
.ExportAsFixedFormat _
Type:=xlTypePDF, _
Filename:="C:\File Name.pdf", _
Quality:=xlQualityStandard, _
IncludeDocProperties:=True, _
IgnorePrintAreas:=False, _
OpenAfterPublish:=True
.Visible = xlSheetHidden
End If
End With
Next ws
End Sub