03-09-19, 10:33 AM
(آخر تعديل لهذه المشاركة : 03-09-19, 10:52 AM {2} بواسطة asemshahen5.)
الطريقة التي تجعلني أقوم بعملية الاستدعاء للدالة :
أولا أضف زر امر ليكن اسمه Button5 و ضع الكود التالي به :
طبعا انت واضع كودك في الفورم :
أولا أضف زر امر ليكن اسمه Button5 و ضع الكود التالي به :
PHP كود :
Private Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click
Dim OpenDoc As New OpenFileDialog
OpenDoc.Filter = "Microsoft Office Word 97-2003 Document(*.doc)|*.doc|Microsoft Office Word 2007-2019 Document(*.docx)|*.docx"
If OpenDoc.ShowDialog = Windows.Forms.DialogResult.OK Then
ConvertWordToPDF(OpenDoc.FileName)
End If
End Sub
طبعا انت واضع كودك في الفورم :
PHP كود :
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
MsgBox("Winn.......")
Catch ex As Exception
MsgBox("Error : " & ex.Message)
'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
سبحان الله وبحمده سبحان الله العظيم و الحمد لله ولا اله الا الله والله اكبر
