locked
Save word as PDF from excel RRS feed

  • Question

  • Hi,

    I have an excel macro that opens a word template, pastes a few things there and saves it as a word document with:

    objWord.ActiveDocument.SaveAs Filename:=patharch2 & "\" & Username & ".docx", _

    FileFormat:=wdFormatXMLDocument, AddToRecentFiles:=False

    But I instead of saving it as a word document I want to save it as PDF, I searched and tried different things but none worked

    With:

    objWord.ActiveDocument.SaveAs2 Filename:=patharch2 & "\" & Username & ".pdf", _

    FileFormat:=wdFormatPDF, AddToRecentFiles:=False

    It creates a PDF, but I can’t open it, it says it’s corrupted.

    Can anybody tell me what I’m doing wrong?

    Thanks in advance

    Tuesday, October 29, 2019 4:02 PM

Answers

  • Use

    objWord.ActiveDocument.ExportAsFixedFormat OutputFileName:=patharch2 & "\" & Username &".pdf", ExportFormat:=17


    Regards, Hans Vogelaar (http://www.eileenslounge.com)

    • Marked as answer by Anonymous1245 Tuesday, October 29, 2019 6:53 PM
    Tuesday, October 29, 2019 4:12 PM

All replies

  • Use

    objWord.ActiveDocument.ExportAsFixedFormat OutputFileName:=patharch2 & "\" & Username &".pdf", ExportFormat:=17


    Regards, Hans Vogelaar (http://www.eileenslounge.com)

    • Marked as answer by Anonymous1245 Tuesday, October 29, 2019 6:53 PM
    Tuesday, October 29, 2019 4:12 PM
  • It worked! thank you!
    Tuesday, October 29, 2019 6:53 PM