+ Reply to Thread
Results 1 to 4 of 4

Thread: Howto save from excel a word as pdf (vba)

  1. #1
    Registered User
    Join Date
    10-10-2011
    Location
    None
    MS-Off Ver
    Excel 2003
    Posts
    2

    Howto save from excel a word as pdf (vba)

    Hello,
    I'm very fresh to vba, so please forgive me for any easy question.
    IIn VBA (excel), I'm opening a word document, filling with values from an xls file and save it. I can save it as .docx but I can't find a way to save it as pdf.
    The code i'm trying to use is:
    ActiveDocument.ExportAsFixedFormat OutputFileName:= ActiveDocument.Path & "\" & ActiveDocument.Name & ".pdf", ExportFormat:= wdExportFormatPDF, OpenAfterExport:=False, OptimizeFor:= wdExportOptimizeForPrint, Range:=wdExportAllDocument, Item:=wdExportDocumentContent, IncludeDocProps:=True, KeepIRM:=True, CreateBookmarks:=wdExportCreateNoBookmarks, DocStructureTags:=True, BitmapMissingFonts:=True, UseISO19005_1:=False
    (from http://vbadud.blogspot.com/2009/07/h...-document.html).
    Vba doesn't recognize all the wd* (enums?).
    Please help
    Last edited by Xristosk; 10-10-2011 at 06:12 PM.

  2. #2
    Valued Forum Contributor Kenneth Hobson's Avatar
    Join Date
    02-05-2007
    Location
    Tecumseh, OK
    MS-Off Ver
    2010
    Posts
    952

    Re: Howto save from excel a word as pdf (vba)

    IF you are using early binding, it would know the values. If you are using late binding, Dim wd as Object, then set the values or use them directly. To find the values, in MSWord's VBE Immediate Window, prefix the constant with a question mark, add the constant variable name, and press enter.

    e.g.
    ?wdExportCreateNoBookmarks
    0

  3. #3
    Registered User
    Join Date
    10-10-2011
    Location
    None
    MS-Off Ver
    Excel 2003
    Posts
    2

    Re: Howto save from excel a word as pdf (vba)

    Nice! I've tried in excel with no result - I should've done it in Word.
    How do I revert the thread to "solved"?

  4. #4
    Valued Forum Contributor Kenneth Hobson's Avatar
    Join Date
    02-05-2007
    Location
    Tecumseh, OK
    MS-Off Ver
    2010
    Posts
    952

    Re: Howto save from excel a word as pdf (vba)

    Of course you can set the reference to MicroSoft Word object in Tools > References and and still use late binding but the constants will still be available.

    From the FAQ:
    To mark your thread solved do the following:
    - Go to the first post
    - Click edit
    - Click Advance
    - Just below the word "Title:" you will see a dropdown with the word No prefix.
    - Change to Solve
    - Click Save

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.2.0