2020年8月5日 星期三

vb.net 將word轉換成pdf [Convert Word to PDF]

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
                Dim strPath As String = "C:\Word.doc"

                Dim MyApp As New Word.Application

                Dim MyWordDoc As Word.Document = MyApp.Documents.Open(strPath, False, False, False, , , False)

                MyApp.Visible = False

                MyWordDoc.SaveAs(FileName:=Path.ChangeExtension(strPath, "pdf"), FileFormat:=Word.WdSaveFormat.wdFormatPDF, _
    LockComments:=False, AddToRecentFiles:=True, ReadOnlyRecommended:=False, _
    EmbedTrueTypeFonts:=False, SaveNativePictureFormat:=True, _
    SaveFormsData:=True, SaveAsAOCELetter:=False, Encoding:=System.Reflection.Missing.Value, InsertLineBreaks:=False, AllowSubstitutions:=False, _
    LineEnding:=Word.WdLineEndingType.wdCRLF, _
    AddBiDiMarks:=False)

                MyWordDoc.Close(False)

                System.Runtime.InteropServices.Marshal.ReleaseComObject(MyWordDoc)

                MyWordDoc = Nothing

                MyApp.Quit()

    End Sub

沒有留言:

張貼留言