Export to PDF not working after compile - SOLVED

Hi again.

I have several macros to print certain sheets to PDF in my spreadsheet. The work in my uncompiled spreadsheet.

After compiling to exe they no longer work. I do have the option to export to PDF selected.

Any help is appreciated. I am using version 2020.1 of XLS Padlock.

Edited to add: It turns out that it does create the document, but it does not open it like it does before compiling. It leaves a blank screen up that you have to close and then go looking for the document.

Is there a way to make it show the PDF after it is created, like it does before compiling?

Could you post the VBA code you’re using to generate the PDF file? Especially the lines that deal with the PDF’s filepath.

Here’s the code for one of them:

Sub CCsummaryPDF(control As IRibbonControl)

Dim PdfFilename As Variant

Sheets("SUMMARY-Cupcakes Information").Select

PdfFilename = Application.GetSaveAsFilename( _
    InitialFileName:="CustomerName_CupcakeSummary", _
    FileFilter:="PDF, *.pdf", _
    Title:="Save As PDF")

If PdfFilename <> False Then

    With ActiveSheet.PageSetup
        .Orientation = xlLandscape
        .PrintArea = "$C$1:$H$24"
        .PrintTitleRows = ActiveSheet.Rows(13).Address
        .Zoom = False
        .FitToPagesTall = False
        .FitToPagesWide = 1
    End With

    ActiveSheet.ExportAsFixedFormat _
        Type:=xlTypePDF, _
        Filename:=PdfFilename, _
        Quality:=xlQualityStandard, _
        IncludeDocProperties:=False, _
        IgnorePrintAreas:=False, _

End If 

End Sub

Can you try to leave OpenAfterPublish to false, and use

Shell "open " PdfFilename


I can try. Where do I insert the
Shell "open " PdfFilename

After ActiveSheet.ExportAsFixedFormat

No, that hung up the program. Task Manager isn’t even closing it. :neutral_face:

Edited to say: I have put it in several places after ActiveSheet.ExportAsFixedFormat
but I get an error:

Compile Error: Expected: End of Statement

with the PdfFilename highlighted

I went on and left the option to open after creating False because it is better than having the weird blank screen open, but I would like the option to open the PDF after creating it to work.

Sure, we’ll check what could be the problem. But maybe it’s a local problem: what is your PDF reader software?

1 Like

I have the full version of Adobe Acrobat on my computer, but Microsoft Edge is the window that opens when creating the PDF. Is there a way to default it to Adobe?

That could be the culprit.
Here is a way to change that:

1 Like

That did the trick for my machine. I will add a note to my instruction manual for my users.


1 Like