02-09-19, 08:41 PM
اخواني الكرام من خلال بحثي عن كيفية تحويل ملف وورد الى ملف pdf وجدت كود يعمل ملفات الاوفيس ابتداءا من الاصدار 2007
لكن مشكلتي هي كيفية استخدام هذا الكود والتعامل معه ExportAsFixedFormat
ما الطريقة التي تجعلني أقوم بعملية الاستدعاء لهذه الدالة
لكن مشكلتي هي كيفية استخدام هذا الكود والتعامل معه ExportAsFixedFormat
ما الطريقة التي تجعلني أقوم بعملية الاستدعاء لهذه الدالة
كود :
Private Sub ConvertWordToPDF(ByVal filename As String)
Dim wordApplication As New Microsoft.Office.Interop.Word.Application
Dim wordDocument As Microsoft.Office.Interop.Word.Document = Nothing
Dim outputFilename As String
Try
wordDocument = wordApplication.Documents.Open(filename)
outputFilename = System.IO.Path.ChangeExtension(filename, "pdf")
If Not wordDocument Is Nothing Then
wordDocument.ExportAsFixedFormat(outputFilename, Microsoft.Office.Interop.Word.WdExportFormat.wdExportFormatPDF, True, Microsoft.Office.Interop.Word.WdExportOptimizeFor.wdExportOptimizeForOnScreen, Microsoft.Office.Interop.Word.WdExportRange.wdExportAllDocument, 0, 0, Microsoft.Office.Interop.Word.WdExportItem.wdExportDocumentContent, True, True, Microsoft.Office.Interop.Word.WdExportCreateBookmarks.wdExportCreateNoBookmarks, True, True, False)
End If
Catch ex As Exception
'TODO: handle exception
Finally
If Not wordDocument Is Nothing Then
wordDocument.Close(False)
wordDocument = Nothing
End If
If Not wordApplication Is Nothing Then
wordApplication.Quit()
wordApplication = Nothing
End If
End Try
End Sub
الحياة فترة اختبار , إما أن تكون او لاتكون
لن امل من البحث ولن امل من السؤال
[b]رواد المعلوميات[/b]