تقييم الموضوع :
  • 0 أصوات - بمعدل 0
  • 1
  • 2
  • 3
  • 4
  • 5
[سؤال] مساعدة في التعامل مع كود
#4
الطريقة التي تجعلني أقوم بعملية الاستدعاء للدالة :

أولا أضف زر امر ليكن اسمه Button5 و ضع الكود التالي به :

PHP كود :
   Private Sub Button5_Click(sender As ObjectAs EventArgsHandles 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(outputFilenameMicrosoft.Office.Interop.Word.WdExportFormat.wdExportFormatPDFTrueMicrosoft.Office.Interop.Word.WdExportOptimizeFor.wdExportOptimizeForOnScreenMicrosoft.Office.Interop.Word.WdExportRange.wdExportAllDocument00Microsoft.Office.Interop.Word.WdExportItem.wdExportDocumentContentTrueTrueMicrosoft.Office.Interop.Word.WdExportCreateBookmarks.wdExportCreateNoBookmarksTrueTrueFalse)
 
           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 
الرد }}}
تم الشكر بواسطة: الرائد , الرائد , ابراهيم ايبو


الردود في هذا الموضوع
RE: مساعدة في التعامل مع كود - بواسطة asemshahen5 - 03-09-19, 10:33 AM


التنقل السريع :


يقوم بقرائة الموضوع: