I have a problem with sheet hiding. I want to print the document, which includes the sheets with a similar name.
I did something like this:
Sub DPPtoPDF()
Dim ws As Worksheet
Sheets("Readme").Visible = False
Sheets("Asbuilt Photos 1").Visible = False
Sheets("Asbuilt Photos 2").Visible = False
Sheets("Splicing Photos").Visible = False
Sheets("Sign Off Sheet").Visible = False
For Each ws In ThisWorkbook.Worksheets
If ws.Name Like "OTDR*" Then
ws.Visible = False
End If
Next was
ThisWorkbook.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
ThisWorkbook.Path & "\" & ThisWorkbook.Name, _
Quality:=xlQualityStandard, IncludeDocProperties:=True, _
IgnorePrintAreas:=False, OpenAfterPublish:=True
Sheets("Readme").Visible = True
Sheets("Asbuilt Photos 1").Visible = True
Sheets("Asbuilt Photos 2").Visible = True
Sheets("Splicing Photos").Visible = True
Sheets("Sign Off Sheet").Visible = True
For Each ws In ThisWorkbook.Worksheets
If ws.Name Like "OTDR*" Then
ws.Visible = True
End If
Next was
Sheets("Frontsheet").Select
End Sub
following the solutions:
https://learn.microsoft.com/en-us/office/vba/api/excel.worksheet.visible
Unhide sheets names using VBA whose name contain specific word
https://excelchamps.com/vba/hide-sheet/
it returns over 2000 pages in my PDF document
What have I done wrong in the code?
I have about 30 sheets at most. How can I exclude (hide) the following sheets from printing it as the PDF?
