Results 1 to 5 of 5
  1. #1
    Thompyt is offline Expert
    Windows 11 Office 365
    Join Date
    Sep 2014
    Location
    El Paso, TX
    Posts
    862

    AForm.Save PDSaveFull, Path Runtime Error 13

    All,


    Previously I had no issue with the "AForm.Save PDSaveFull, Path" command. Now I get where PDSaveFull = Nothing. Path is correct. When the file is attached to the email, there is no sig box, but in the temp directory the file has a sig box. It seems that it is being saved but not being attached.

    Exmples
    TODA = todays date time group 141306TApr2025
    FName = First intiial and last name
    FT= Fort Code FRKS (Fort Riley Kansas)
    GT = Ground Travel
    EmailSub - preprepared text message for subject line


    Code:
    Public Sub ExportTARRpt_Click()Dim TODA As String, FName As String, Rev As String, FT As String, GT As String, InputPDF As String
    
    
    On Error GoTo Error1
        TODA = DLookup("[TODA]", "[QryTAR]")
        FName = DLookup("[FNames]", "[QryTAR]")
        FT = DLookup("[FTCode]", "[QryTAR]")
        GT = DLookup("[GNDTVL]", "[QryTAR]")
    
    
        DoCmd.OutputTo 3, "RptTAR", acFormatPDF, "C:\TEMP\" & "QF XXX(" & FName & ")" & TODA & "(" & [FT] & ")-" & TOD & ".pdf", , 0
        
        If GT = True Then
            Call Form_FrmCostComp.CostComp_Click
        End If
        
        InputPDF = "C:\TEMP\" & "QF XXX(" & FName & ")" & TODA & "(" & [FT] & ")-" & TOD & ".pdf"
        
        Call AddSigBoxes
        
        Exit Sub
    
    
    Error1:
    MsgBox "Please select records first."
    End Sub
    
    
    Public Sub AddSigBoxes()
    Dim App As Object, AVdoc As Object, AForm As Object, PDSaveFull As Object
    Dim TODA As String, FName As String, FT As String, Path As String, js As String, Cord As String
    
    
    'On Error GoTo Err_Handler
        TODA = DLookup("[TODA]", "[QryTAR]")
        FT = DLookup("[FTCode]", "[QryTAR]")
        FName = DLookup("[FNames]", "[QryTAR]")
        
        Cord = "[218," & 281 & ",394," & 226 & "]"
    '            LFT     BTM     RT      Top
        Path = "C:\TEMP\" & "QF XXX(" & FName & ")" & TODA & "(" & [FT] & ")-" & TOD & ".pdf"
        
        Set App = CreateObject("Acroexch.app")
            App.Hide
        Set AVdoc = CreateObject("AcroExch.AVDoc")
        Set AForm = CreateObject("AFormAut.App")
    
    
        If AVdoc.Open(Path, "") Then
            js = "f = this.addField(""SignatureField2"", ""signature"", 0, " & Cord & ");" & "f.value = ""Approval""; " & "f.flatten"
                AForm.Fields.ExecuteThisJavaScript js
    
    
        Set AForm = AVdoc.GetPDDoc
           AForm.Save PDSaveFull, Path
                AVdoc.Close False
        End If
    
    
        App.Exit
    
    
        Set App = Nothing
        Set AVdoc = Nothing
        Set AForm = Nothing
        Path = ""
        
    Exit_Proc:
        Exit Sub
    
    
    Err_Handler:
        MsgBox "Error: " & Err.Number & " - " & Err.Description & "  You need Adobe Pro."
        Resume Exit_Proc
    
    
    End Sub
    
    Public Sub SendTAR_Click()
    Dim objOutlook As Outlook.Application
    Dim objOutlookMsg As Outlook.MailItem
    Dim objOutlookAttach As Outlook.Attachment
    Dim objOutlookRecip As Outlook.Recipient
    Dim GrpEMails As Variant
    Dim TODA As String, FNames As String, FName As String, PName As String, FT As String, GT As String, EmailSub As String
       
        TODA = DLookup("[TODA]", "[QryTAR]")
        FT = DLookup("[FTCode]", "[QryTAR]")
        GT = DLookup("[GNDTVL]", "[QryTAR]")
        EmailSub = DLookup("[EmailSub]", "[QryTAR]")
        FName = DLookup("[FNames]", "[QryTAR]")
        
        If PAXCheck = True Then
            FNames = DLookup("[FNames]", "[QryTAR]") & "-" & DLookup("[PName]", "[QryCostComp]")
        Else
            FNames = DLookup("[FNames]", "[QryTAR]")
        End If
        
    Call ExportTARRpt_Click
        
        Set objOutlook = CreateObject("Outlook.Application")
        Set objOutlookMsg = objOutlook.CreateItem(olMailItem)
    
    
        With objOutlookMsg
            .Subject = "QF XXX (" & [FNames] & ") " & EmailSub
            .Body = "Please verify the attached is correct." & vbCrLf & vbCrLf & vbCrLf & SigBlock
            
            If GT = True Then
                .Attachments.Add ("C:\TEMP\" & "CostComp(" & [FNames] & ")" & [TODA] & "(" & [FT] & ")-" & TOD & ".xlsx") ', AccessMode:=xlExclusive, ConflictResolution:=xlLocalSessionChanges
            End If
    
    
            .Attachments.Add ("C:\TEMP\" & "QF XXX(" & FName & ")" & TODA & "(" & [FT] & ")-" & TOD & ".pdf")
            .To = "Alfredo.Ramirez@serco-na.com"
            .Display
        End With
    
    
     '   Kill ("C:\TEMP\" & "QF XXX(" & FName & ")" & TODA & "(" & [FT] & ")-" & TOD & ".pdf")
        On Error Resume Next
            Kill ("C:\TEMP\" & "CostComp(" & [FNames] & ")" & [TODA] & "(" & [FT] & ")-" & TOD & ".xlsx")
        
        Set objOutlookMsg = Nothing
        Set objOutlook = Nothing
        Set objOutlookAttach = Nothing
           
    Call CloseRpt_Click
            
    End Sub

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 11 Access 2021
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    If it worked before, what changed?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    jojowhite's Avatar
    jojowhite is online now Competent Performer
    Windows 11 Access 2021
    Join Date
    Jan 2025
    Posts
    434
    only, comment.
    on your Sub ExportTARRpt_Click, parameter GT is declared as String, while on the
    code you are checking it's value as True.
    the sub also is missing the closing (right) parenthesis on it's declaration.

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 11 Access 2021
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    jojo, I don't think paren is missing. This forum tends to merge first two lines of code. Note Dim statement on same line as procedure declaration.

    I always have to edit by entering a CR to break the line.

    Very annoying.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    Micron is offline Very Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,423
    Is it guaranteed that QryTAR will only have one record? If not, then you probably need criteria on those DLookups. Rather than look up the same values in the called Sub, add FT and TODA as parameters in the called sub and pass them from the calling sub. I'm assuming the single record of the query would be the same as it was before.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

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

Similar Threads

  1. Replies: 1
    Last Post: 07-12-2023, 08:24 AM
  2. Replies: 8
    Last Post: 10-12-2020, 01:19 PM
  3. Replies: 2
    Last Post: 08-22-2018, 12:15 PM
  4. Replies: 6
    Last Post: 05-27-2014, 05:41 AM
  5. Replies: 3
    Last Post: 11-24-2012, 08:56 AM

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