AnsweredAssumed Answered

Save As PDF Macro, Not Save Certain Sheets

Question asked by Brennan Sheremeto on Apr 15, 2016
Latest reply on Aug 21, 2016 by Deepak Gupta

Hi,

 

I'm writing a save as PDF macro and I have it working properly except for I don't want it to save sheets named "DXF" in the PDF file. Here is the code I have (from another post on here) to strip out the PDFs with DXF in the name.

 

'GET PDF DATA AND SAVE

Set swExportPdfData = swApp.GetExportFileData(swExportDataFileType_e.swExportPdfData)

  

    ReDim strSheetName(0)

    Dim s As Variant

    For Each s In swDrawDoc.GetSheetNames

        If Not UCase(s) Like "*DXF*" Then

            strSheetName(UBound(strSheetName)) = s

            ReDim Preserve strSheetName(UBound(strSheetName) + 1)

        End If

    Next s

  

    varSheetName = strSheetName

    If swExportPdfData Is Nothing Then MsgBox "Nothing"

    boolstatus = swExportPdfData.SetSheets(swExportData_ExportSpecifiedSheets, varSheetName)

  

boolstatus = swModelDocExt.SaveAs(SavePath, 0, 0, swExportPdfData, lErrors, lWarnings)

 

However the DXF sheet still gets saved.

Outcomes