Results 1 to 3 of 3
  1. #1
    SGrohola is offline Advanced Beginner
    Windows 10 Access 2013 64bit
    Join Date
    Mar 2017
    Location
    Romulus, MI
    Posts
    41

    Code works with Adobe Acrobat - need it to work with Adobe Reader

    Hello. I have an Access database, that has several command buttons that populates pdf forms with data from Access. It works great on my computer, but I have the full Adobe Acrobat program. I need it to be able to work with Adobe Reader, and I'm not sure if I have to change my code for this. I have 2 other co-workers that need to use it, and it's not working on theirs. When I tried to run it from their system, it err'd out on the module.

    Can anyone help?



    I have one module code:
    Code:
    Option Compare Database
    Option Explicit
    
    
    Private Declare PtrSafe Function apiShellExecute Lib "shell32.dll" _
        Alias "ShellExecuteA" _
        (ByVal hWnd As Long, _
        ByVal lpOperation As String, _
        ByVal lpFile As String, _
        ByVal lpParameters As String, _
        ByVal lpDirectory As String, _
        ByVal nShowCmd As Long) _
        As LongPtr
    
    
    'ShowWindow Enum
    Public Enum eSE_ShowWindow
      seswHide = 0
      seswNormal = 1
      seswShowMinimized = 2
      seswShowMaximized = 3
      seswShowNoActivate = 4
      seswShow = 5
      seswMinimize = 6
      seswShowMinNoActive = 7
      seswShowNA = 8
      seswRestore = 9
      seswShowDefault = 10
      seswForceMinimize = 11
      seswMax = 12
    End Enum
    
    
    
    
    'Operation enum
    Public Enum eSE_Operation
      seopDefault = -1
      seopOpen = 0
      seopPrint = 1
      seopExplore = 2
      seopRead = 3
      seopProperties = 4
    End Enum
    
    
    '============================================================================
    ' NAME: ShellEx
    ' DESC: Calls ShellExecute API
    '============================================================================
    'ErrStrV3.00
    Public Function ShellEx( _
      sFile As String, _
      Optional iOperation As eSE_Operation = seopDefault, _
      Optional sParameters As String = "", _
      Optional sDirectory As String = "", _
      Optional lShowCmd As eSE_ShowWindow = seswNormal, _
      Optional lHand As Long = 0 _
      ) As Boolean
    On Error GoTo Error_Proc
    Dim Ret As Boolean
    '=========================
      Dim sOp As String
    '=========================
    
    
      Select Case iOperation
        Case seopOpen: sOp = "open"
        Case seopPrint: sOp = "print"
        Case seopExplore: sOp = "explore"
        Case seopRead: sOp = "read"
        Case seopDefault: sOp = vbNullChar
        Case seopProperties: sOp = "properties"
        Case Else: sOp = vbNullChar
      End Select
      
      If Len(sParameters) = 0 Then sParameters = vbNullString
      If Len(sDirectory) = 0 Then sDirectory = vbNullString
      
      Ret = IIf(apiShellExecute(lHand, sOp, sFile, sParameters, sDirectory, lShowCmd) > 32, True, False)
      
    '=========================
    Exit_Proc:
      ShellEx = Ret
      Exit Function
    Error_Proc:
      MsgBox "Error: " & Trim(Str(Err.Number)) & vbCrLf & _
        "Desc: " & Err.Description & vbCrLf & vbCrLf & _
        "Module: basShellExecute, Procedure: ShellEx" _
        , vbCritical, "Error!"
      Resume Exit_Proc
      Resume
    
    
    End Function

    And this is the code for the pdf form.




    Code:
    Private Sub Command41_Click()
    
    
    'theDBguy@gmail.com
    '4/10/2012
    
    
    'This demo creates a XFDF file to merge with a fillable PDF form.
    'Using this method avoids the need to use an Acrobat DLL to manipulate the PDF file.
    'This method relies on the capabilities of the installed PDF reader.
    
    
    'Declare the PDF file to be filled and assume it's in the same directory as the database
    Const strPDF As String = "URS Midwest ICSA 16.2.pdf"
    
    
    'Declare the XFDF file to use
    Const strXFDF As String = "URS Midwest ICSA.xfdf"
    
    
    Dim strPath As String
    Dim intFile As Integer
    
    
    strPath = CurrentProject.Path
    intFile = FreeFile
    
    
    'Create XFDF file
    Open strPath & "\" & strXFDF For Output As #intFile
    
    
    'This is where I need to change the field names to match my pdf formm.
    
    
    Print #intFile, "<?xml version=""1.0"" encoding=""UTF-8""?>"
    Print #intFile, "<xfdf xmlns=""http://ns.adobe.com/xfdf/"" xml:space=""preserve"">"
    Print #intFile, "<f href=""" & strPDF & """/>"
    Print #intFile, "<fields>"
    Print #intFile, "<field name=""TruckNo"">"
    Print #intFile, "<value>" & Me.TruckNo & "</value>"
    Print #intFile, "</field>"
    Print #intFile, "<field name=""TrailerUnitNo"">"
    Print #intFile, "<value>" & Me.TrailerUnitNo & "</value>"
    Print #intFile, "</field>"
    Print #intFile, "<field name=""DBA"">"
    Print #intFile, "<value>" & Me.DBA & "</value>"
    Print #intFile, "</field>"
    Print #intFile, "<field name=""TractorYear"">"
    Print #intFile, "<value>" & Me.TractorYear & "</value>"
    Print #intFile, "</field>"
    Print #intFile, "<field name=""TractorMake"">"
    Print #intFile, "<value>" & Me.TractorMake & "</value>"
    Print #intFile, "</field>"
    Print #intFile, "<field name=""TractorVIN"">"
    Print #intFile, "<value>" & Me.TractorVIN & "</value>"
    Print #intFile, "</field>"
    Print #intFile, "<field name=""TrailerYear"">"
    Print #intFile, "<value>" & Me.TrailerYear & "</value>"
    Print #intFile, "</field>"
    Print #intFile, "<field name=""Trailermake"">"
    Print #intFile, "<value>" & Me.Trailermake & "</value>"
    Print #intFile, "</field>"
    Print #intFile, "<field name=""TrailerVIN"">"
    Print #intFile, "<value>" & Me.TrailerVIN & "</value>"
    Print #intFile, "</field>"
    Print #intFile, "<field name=""Expr1"">"
    Print #intFile, "<value>" & Me.Expr1 & "</value>"
    Print #intFile, "</field>"
    Print #intFile, "<field name=""OwnerAddress1"">"
    Print #intFile, "<value>" & Me.OwnerAddress1 & "</value>"
    Print #intFile, "</field>"
    Print #intFile, "<field name=""OwnerAddress2"">"
    Print #intFile, "<value>" & Me.OwnerAddress2 & "</value>"
    Print #intFile, "</field>"
    Print #intFile, "<field name=""Expr2"">"
    Print #intFile, "<value>" & Me.Expr2 & "</value>"
    Print #intFile, "</field>"
    Print #intFile, "</fields>"
    Print #intFile, "</xfdf>"
    
    
    Close #intFile
    
    
    'Open the PDF file
    ShellEx strPath & "\" & strXFDF
    
    
    
    
    End Sub

  2. #2
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,413
    if the code is intended to work with full version of acrobat you need to have the full version of acrobat installed. Reader just won't hack it.

    Edit - just noticed it is not intended to run with acrobat, but accesses an online adodb facility. Think you will need to find out which line it errors on

  3. #3
    SGrohola is offline Advanced Beginner
    Windows 10 Access 2013 64bit
    Join Date
    Mar 2017
    Location
    Romulus, MI
    Posts
    41
    Thanks.... I just noticed that as well. The error is showing when the module runs. I will have to rerun it on my co-worker's computer to get the exact line that it errors on.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 4
    Last Post: 10-04-2015, 02:04 PM
  2. Opening PDF File in Acrobat Reader
    By Robert2150 in forum Macros
    Replies: 2
    Last Post: 05-05-2014, 01:04 PM
  3. Replies: 1
    Last Post: 04-18-2014, 10:03 AM
  4. Replies: 5
    Last Post: 01-23-2014, 09:36 AM
  5. How do you(Acccess to Adobe in VBA)
    By Madmax in forum Access
    Replies: 10
    Last Post: 06-28-2012, 04:18 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums