Im after code to convert Word to PDF (1 Viewer)

Lanason

Registered User.
Local time
Today, 19:55
Joined
Sep 12, 2003
Messages
258
Hello Everyone,

I'm looking for some simple code to copy a ABC.docx into a ABC.pdf format . . I can do all the paths / filenames etc just need the bit to convert/export/save

Thank you in advance
 

theDBguy

I’m here to help
Staff member
Local time
Today, 11:55
Joined
Oct 29, 2018
Messages
21,527
Hello Everyone,

I'm looking for some simple code to copy a ABC.docx into a ABC.pdf format . . I can do all the paths / filenames etc just need the bit to convert/export/save

Thank you in advance
Yeah, you mean like "Save As" to PDF using code? If so, did you want to use the code within Word or Access?
 

onur_can

Active member
Local time
Today, 11:55
Joined
Oct 4, 2015
Messages
180
The code below can help.

Code:
 Alt SaveAsWordToPDF ()

    Dim strFileName As String
    WordApp Olarak Sönük WordAppApp

    strpath = "F: \ PDF Dosyaları \"
    strFileName = "ABC.docx"


    Set WordApp = CreateObject ("Word.Application")
    WordApp.Documents.Open strpath & strFileName
           
'.doc veya .docx'i dosya adından kaldır
    UCase (Sağ (ActiveDocument.name, 1)) = "X"
'.docx
        strFileName = Sol (ActiveDocument.name, Len (ActiveDocument.name) - 5)
    Başka
'.doc
        strFileName = Sol (ActiveDocument.name, Len (ActiveDocument.name) - 4)
    End If

'PDF dosyasını yaz
    WordApp.ActiveDocument.ExportAsFixedFormat _
            OutputFileName: = ActiveDocument.Path & "\" & strFileName & ".pdf", _
            ExportFormat: = wdExportFormatPDF, _
            OpenAfterExport: = Yanlış, _
            OptimizeFor: = wdExportOptimizeForPrint, _
            Aralık: = wdExportAllDocument, _
            Öğe: = wdExportDocumentContent, _
            IncludeDocProps: = Doğru, KeepIRM: = Doğru, _
            CreateBookmarks: = wdExportCreateNoBookmarks, _
            DocStructureTags: = Doğru, _
            BitmapMissingFonts: = Doğru, _
            UseISO19005_1: Yanlış =

    WordApp.Quit
    WordApp Ayarla = Hiçbir şey

' hepsi tamam
    MsgBox "PDF tamamlandı"

End Sub
[/ CODE]


Don't forget, you'll need a reference to the Microsoft Word Object Library for this to work.
 

Users who are viewing this thread

Top Bottom