Results 1 to 8 of 8
  1. #1
    rtiql8n's Avatar
    rtiql8n is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Aug 2014
    Posts
    4

    Unhappy pdf issue after upgrading from 2003 to 2013

    Hello all,

    I am not very good with access code but here is my issue: We create a Work Order and print that for each call. Works fine. If we click on "Email Work Order" it converts it to a pdf , and attaches it to Outlook. This worked seamlessly in XP/2003 version. Just upgraded to Windows 7 and Office 2013 and when you email the same Work Order, it flips it to landscape (11"x8.5") but not any of the characters so it's cropped. Is it something in the code? See code below. And thank you all in advance.

    Private Sub E_Mail_Work_Order_Click()
    'On Error GoTo Err_E_Mail_Work_Order_Click

    Dim stDocName As String

    DoCmd.RunCommand acCmdSaveRecord
    Set db = CurrentDb
    strFrontEndPath = db.Name
    Do While Right(strFrontEndPath, 1) <> "\"
    strFrontEndPath = Left(strFrontEndPath, Len(strFrontEndPath) - 1)
    Loop
    strReportPathandName = strFrontEndPath & "WorkOrder-" & Forms!Callsheet!WO & ".pdf"
    'MsgBox strReportPathandName
    Call ConvertReportToPDF("Work Order", , strReportPathandName, , False)

    'stDocName = "Work Order"
    'DoCmd.SendObject acReport, strReportPathandName

    Dim myolApp As Outlook.Application


    Dim myItem As Outlook.MailItem
    Dim strDataFileName As String

    Set myolApp = CreateObject("Outlook.Application")
    Set myItem = myolApp.CreateItem(olMailItem)

    strEmail = Nz(DLookup("fldCustomerEmail", "tblCustomerPerson", "fldCustomerID = " & Me.fldCustomerID))

    myItem.To = strEmail
    myItem.Subject = "Docu-Flow = Work Order # " & Me.WO

    myItem.Attachments.Add strReportPathandName
    'myItem.Send
    myItem.Display

    Exit_E_Mail_Work_Order_Click:
    Exit Sub

    Err_E_Mail_Work_Order_Click:
    MsgBox Err.Description
    Resume Exit_E_Mail_Work_Order_Click

    End Sub

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    First try editing the report to allow for a larger margin. Shouldn't need much.

    I don't see anything in that code to cause issue.

    What is code for ConvertReportToPDF procedure?
    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
    rtiql8n's Avatar
    rtiql8n is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Aug 2014
    Posts
    4
    Here is the code:
    Public Function ConvertReportToPDF( _
    Optional RptName As String = "", _
    Optional SnapshotName As String = "", _
    Optional OutputPDFname As String = "", _
    Optional ShowSaveFileDialog As Boolean = False, _
    Optional StartPDFViewer As Boolean = True, _
    Optional CompressionLevel As Long = 0, _
    Optional PasswordOwner As String = "", _
    Optional PasswordOpen As String = "", _
    Optional PasswordRestrictions As Long = 0, _
    Optional PDFNoFontEmbedding As Long = 0 _
    ) As Boolean


    ' RptName is the name of a report contained within this MDB
    ' SnapshotName is the name of an existing Snapshot file
    ' OutputPDFname is the name you select for the output PDF file
    ' ShowSaveFileDialog is a boolean param to specify whether or not to display
    ' the standard windows File Dialog window to select an exisiting Snapshot file
    ' CompressionLevel - not hooked up yet
    ' PasswordOwner - not hooked up yet
    ' PasswordOpen - not hooked up yet
    ' PasswordRestrictions - not hooked up yet
    ' PDFNoFontEmbedding - Do not Embed fonts in PDF. Set to 1 to stop the
    ' default process of embedding all fonts in the output PDF. If you are
    ' using ONLY - any of the standard Windows fonts
    ' using ONLY - any of the standard 14 Fonts natively supported by the PDF spec
    'The 14 Standard Fonts
    'All version of Adobe's Acrobat support 14 standard fonts. These fonts are always available
    'independent whether they're embedded or not.
    'Family name PostScript name Style
    'Courier Courier fsNone
    'Courier Courier-Bold fsBold
    'Courier Courier-Oblique fsItalic
    'Courier Courier-BoldOblique fsBold + fsItalic
    'Helvetica Helvetica fsNone
    'Helvetica Helvetica-Bold fsBold
    'Helvetica Helvetica-Oblique fsItalic
    'Helvetica Helvetica-BoldOblique fsBold + fsItalic
    'Times Times-Roman fsNone
    'Times Times-Bold fsBold
    'Times Times-Italic fsItalic
    'Times Times-BoldItalic fsBold + fsItalic
    'Symbol Symbol fsNone, other styles are emulated only
    'ZapfDingbats ZapfDingbats fsNone, other styles are emulated only




    Dim s As String
    Dim blRet As Boolean
    ' Let's see if the DynaPDF.DLL is available.
    blRet = LoadLib()
    If blRet = False Then
    ' Cannot find DynaPDF.dll or StrStorage.dll file
    Exit Function
    End If

    On Error GoTo ERR_CREATSNAP

    Dim strPath As String
    Dim strPathandFileName As String
    Dim strEMFUncompressed As String

    Dim sOutFile As String
    Dim lngRet As Long

    ' Init our string buffer
    strPath = Space(Pathlen)

    'Save the ReportName to a local var
    mReportName = RptName

    ' Let's kill any existing Temp SnapShot file
    If Len(mUncompressedSnapFile & vbNullString) > 0 Then
    Kill mUncompressedSnapFile
    mUncompressedSnapFile = ""
    End If

    ' If we have been passed the name of a Snapshot file then
    ' skip the Snapshot creation process below
    If Len(SnapshotName & vbNullString) = 0 Then

    ' Make sure we were passed a ReportName
    If Len(RptName & vbNullString) = 0 Then
    ' No valid parameters - FAIL AND EXIT!!
    ConvertReportToPDF = ""
    Exit Function
    End If

    ' Get the Systems Temp path
    ' Returns Length of path(num characters in path)
    lngRet = GetTempPath(Pathlen, strPath)
    ' Chop off NULLS and trailing "\"
    strPath = Left(strPath, lngRet) & Chr(0)

    ' Now need a unique Filename
    ' locked from a previous aborted attemp.
    ' Needs more work!
    strPathandFileName = GetUniqueFilename(strPath, "SNP" & Chr(0), "snp")

    ' Export the selected Report to SnapShot format
    DoCmd.OutputTo acOutputReport, RptName, "SnapshotFormat(*.snp)", _
    strPathandFileName
    ' Make sure the process has time to complete
    DoEvents

    Else
    strPathandFileName = SnapshotName

    End If

    ' Let's decompress into same filename but change type to ".tmp"
    'strEMFUncompressed = Mid(strPathandFileName, 1, Len(strPathandFileName) - 3)
    'strEMFUncompressed = strEMFUncompressed & "tmp"
    Dim sPath As String * 512
    lngRet = GetTempPath(512, sPath)

    strEMFUncompressed = GetUniqueFilename(sPath, "SNP", "tmp")

    lngRet = SetupDecompressOrCopyFile(strPathandFileName, strEMFUncompressed, 0&)

    If lngRet <> 0 Then
    Err.Raise vbObjectError + 525, "ConvertReportToPDF.SetupDecompressOrCopyFile" , _
    "Sorry...cannot Decompress SnapShot File" & vbCrLf & _
    "Please select a different Report to Export"
    End If

    ' Set our uncompressed SnapShot file name var
    mUncompressedSnapFile = strEMFUncompressed

    ' Remember to Cleanup our Temp SnapShot File if we were NOT passed the
    ' Snapshot file as the optional param
    If Len(SnapshotName & vbNullString) = 0 Then
    Kill strPathandFileName
    End If


    ' Do we name output file the same as the input file name
    ' and simply change the file extension to .PDF or
    ' do we show the File Save Dialog
    If ShowSaveFileDialog = False Then

    ' let's decompress into same filename but change type to ".tmp"
    ' But first let's see if we were passed an output PDF file name
    If Len(OutputPDFname & vbNullString) = 0 Then
    sOutFile = Mid(strPathandFileName, 1, Len(strPathandFileName) - 3)
    sOutFile = sOutFile & "PDF"
    Else
    sOutFile = OutputPDFname
    End If

    Else
    ' Call File Save Dialog
    sOutFile = fFileDialog()
    If Len(sOutFile & vbNullString) = 0 Then
    Exit Function
    End If

    End If

    ' Call our function in the StrStorage DLL
    ' Note the Compression and Password params are not hooked up yet.
    'sOutFile = "C:\X.pdf"
    blRet = False
    blRet = ConvertUncompressedSnapshot(mUncompressedSnapFile, sOutFile, _
    CompressionLevel, PasswordOwner, PasswordOpen, PasswordRestrictions, PDFNoFontEmbedding)

    If blRet = False Then
    Err.Raise vbObjectError + 526, "ConvertReportToPDF.ConvertUncompressedSnaphot ", _
    "Sorry...damaged SnapShot File" & vbCrLf & _
    "Please select a different Report to Export"
    End If

    ' Do we open new PDF in registered PDF viewer on this system?
    If StartPDFViewer = True Then
    ShellExecuteA Application.hWndAccessApp, "open", sOutFile, vbNullString, vbNullString, 1
    End If

    ' Success
    ConvertReportToPDF = True


    EXIT_CREATESNAP:

    ' Let's kill any existing Temp SnapShot file
    'If Len(mUncompressedSnapFile & vbNullString) > 0 Then
    On Error Resume Next
    Kill mUncompressedSnapFile
    mUncompressedSnapFile = ""
    'End If

    ' If we aready loaded then free the library
    If hLibStrStorage <> 0 Then
    hLibStrStorage = FreeLibrary(hLibStrStorage)
    End If

    If hLibDynaPDF <> 0 Then
    hLibDynaPDF = FreeLibrary(hLibDynaPDF)
    End If

    Exit Function

    ERR_CREATSNAP:
    MsgBox Err.Description, vbOKOnly, Err.Source & ":" & Err.Number
    mUncompressedSnapFile = ""
    ConvertReportToPDF = False
    Resume EXIT_CREATESNAP

    End Function

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    Sorry I asked, that's a lot of code! At first glance, don't see anything that would cause issue.
    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
    rtiql8n's Avatar
    rtiql8n is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Aug 2014
    Posts
    4
    Is it possible that by converting from a .snp to a .pdf is where the formatting (paper size/orientation) problem exists? If so, how would I make the change in the snapshot? When I view the Work Order in "Reports" it looks perfect. In fact, If I "create a pdf from that view on my screen it works fine. Its just too many steps for someone to do and they could click on the wrong things back there. Stumped.

  6. #6
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    I've never used .snp file. You are saving report as snp and then converting to pdf for attachment to email?

    Are you saying it is too complicated for user to right click on the report and manually export to pdf? How is the snp file created?

    Report can be exported directly to pdf using VBA with the DoCmd.OutputTo method.
    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.

  7. #7
    rtiql8n's Avatar
    rtiql8n is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Aug 2014
    Posts
    4
    About halfway down the code is the DoCmd.OutputTo. I'm not sure weather this code is from the 1999 version that we originally wrote, or weather its embedded in the 2013 version that we are using now. I think its part of the original code. So, if I try to re-write that code it may corrupt the whole thing? But again I am not the original designer and have been given this task to resolve. ugh. ALSO, I did try changing the margins. I get 0 results with that. I think the margins are set at .17 top and bottom already.

  8. #8
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    If you output direct to PDF, certainly have to rewrite some code. Create a new procedure SaveToPDF and call that instead. Some of the old code may be relevant, such as constructing the file name.
    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.

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

Similar Threads

  1. Replies: 22
    Last Post: 02-24-2014, 10:21 PM
  2. Replies: 8
    Last Post: 10-10-2013, 12:27 PM
  3. Replies: 15
    Last Post: 07-17-2013, 11:29 AM
  4. Access 2013 Display Issue?
    By Alan S in forum Access
    Replies: 2
    Last Post: 05-26-2013, 03:21 PM
  5. Replies: 2
    Last Post: 05-24-2013, 08:17 AM

Tags for this Thread

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