0 Replies Latest reply on Oct 5, 2010 4:13 AM by Master-Rudi

    AdobePDFMakerX and VBA

    Master-Rudi Level 1

      Hello,

       

      Iám trying to use Acrobat to convert files like Word, Excel or Pictures in Access by clicking a button.

       

      I have tryed much, but it didn´t work.

       

      I found the following VBa code, but it doesn´t work. But there is no warning in Access and the code seems to be good, but there is no output.

       

      Does any body know the Problem?

       

      Or ist ist possible to do this with a batch file?

       

       

      Private Sub Befehl1_Click()


      'Items needed to convert Word Doc to PDF
      Dim strPDFDoc As New AdobePDFMakerX.Word
      Dim strPDFName As String 'Format: "C:|My Documents\Test.pdf"
      Dim strWordName As String 'Format: "C:\My Documents\Test.doc"

      strPDFName = "D:\Test\1.pdf"
      strWordName = "D:\Test\1.doc"
      'Then within a loop that cycles thru all of your Documents

          'Convert the document to PDF format
           Set strPDFDoc = CreateObject("AdobePDFMakerx.Word")
           If strPDFDoc.CreatePDF(strWordName, strPDFName) Then
               MsgBox "Fertig"
               'Wait (10)
           Else
               'there was a problem
               MsgBox "Fehler"
           End If

      'End Loop

      End Sub

       

      Or another code, I think it works in the same way, but is a little bit nicer

       

      Private Sub Befehl2_Click()
      Dim PDFMaker As AdobePDFMakerX.Word
      Set PDFMaker = New AdobePDFMakerX.Word
         
          PDFMaker.WordFilename = "D:\Test\1.doc"
          PDFMaker.ActivateWordAndAcrobat
         
          Dim PDFMakerOptions As AdobePDFMakerX.Options
          Dim PDFMakerHeading As AdobePDFMakerX.WordHeadings
          Dim retval As Long
         
          Set PDFMakerOptions = PDFMaker.Options
          With PDFMakerOptions
              .DeletePSAndLogFiles = False
              .SendViaEmail = False
         
              ' Office tab - General section
              .ConvertDocInfo = True
              .CrossDocLinks = True
              .InternetLinks = True
              .LinkMagnification = pdfMakerMagDefault
              .AutoSaveFile = True
             
              ' Office tab - Word Features section
              .TextNotes = True
              .Threads = True
              .PageLabels = False
              .CrossRefLinks = True
              .FootnoteLinks = True
         
              ' Office tab - Document Tag section
              .AllowAccessibility = True
             
              ' Bookmarks tab
              retval = .Bookmarks(pdfMakerBookmarksFromStyles)
              .BookmarkMagnification = pdfMakerMagDefault
             
              ' Display tab - Document Open Options section
              .ShowBookmarkPane = True
              .FirstPageNumber = 1
              .PageMagnification = pdfMaker100
             
              ' Display tab - Document Open Options section
              .LinkType = pdfMakerLinkTypeInvisible
          End With
         
          Set PDFMakerHeading = PDFMakerOptions.Headings
          With PDFMakerHeading
              .AddStyle "C-Heading 1", False, 1
              .ConvertToBookmark("C-Heading 1") = True
              .MarkAsStructuredContent("C-Heading 1") = False
          End With
         
          retval = PDFMaker.CreatePDF("D:\Test\1.doc", "D:\Test\1.pdf")
          Debug.Print Now(), retval
         
          Set PDFMaker = Nothing
      End Sub

       

      Can anybody help me with that`?

       

      Thank you!