It's always done through an object (variable) or a class in the case of Shared methods such as ReleaseComObject. NET, so you still have to get the way things are going. Private Sub CreateTitlePage() Dim wdApp As .Application = New .Application Dim wdDoc As .Document = New .Document Dim wdPara1 As .Paragraph 'Dim wd As .Page = False = WdVerticalAlignment.wdAlignVerticalCenter wdPara1 = () = "BINDER DOCUMENT" + vbVerticalTab + vbVerticalTab + "Created on: " + formattedDate2 = True = WdParagraphAlignment.wdAlignParagraphCenter ' The following statements save the document and close the Word application wdDoc.SaveAs(binderNameDoc) wdDoc.Close() wdApp.Quit() ConvertWordToPDF(tbProject.Text + "\", "Binder" + formattedDate, docLit) End Sub Public Sub ConvertWordToPDF(myPathName As String, myFileName As String, myFileExt As String) Dim myWordName As String = myPathName + myFileName + myFileExt Dim myPDFName As String = myPathName + myFileName + pdfLit Dim word As .Application = New .Application() Dim doc As .Document = (myWordName) Dim doc2 As PdfDocument = New PdfDocument doc.Activate() doc.SaveAs2(myPDFName, WdSaveFormat.wdFormatPDF) doc.Close() ReDim Preserve pdfArray(pdfArray.Length) pdfArray(countConversions) = myPDFName countConversions = countConversions + 1 End SubÄon't be sorry. I'm very new to VB coding and would appreciate any help. I've tried it with no value, a 1 and a 2, but I'm still getting the "file in use" error when I try to delete it. I've tried using the FileClose() method but it only accepts an integer as a parameter. The code below closes the Word document but not the PDF. It seems like all I should need to do would be to close the file, but I'm not sure how to do that. My problem is that when I try to delete the PDF file later in the application, it tells me that it is still in use. The code below creates a PDF file by converting a simple Word file using the Doc.SaveAs2 method with the PDF parameter for the format. I am running Visual Studio 2015 Community, visual basic.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |