Excel crashes printing A/R invoices through VBA - MSVCR120.dll

SUGGESTED

I have some macro code that is printing A/R Invoices to PDF files.

The code works fine on my laptop, but on the client workstation, it crashes.  Event Viewer identifies MSVCR120.DLL as the problem.

The OS and Excel versions are identical on the workstation compared to my laptop.

Has anyone run into this issue?  I've tried replacing the MSVCR120.DLL file with the one on my laptop, but no success.

This is the event viewer details:

Faulting application name: EXCEL.EXE, version: 16.0.8067.2115, time stamp: 0x5918bd78
Faulting module name: MSVCR120.dll, version: 12.0.21005.1, time stamp: 0x524f7ce6
Exception code: 0xc0000005
Fault offset: 0x000183f3
Faulting process id: 0x2054
Faulting application start time: 0x01d2dfac53345b53
Faulting application path: C:\Program Files (x86)\Microsoft Office\Root\Office16\EXCEL.EXE
Faulting module path: C:\WINDOWS\SYSTEM32\MSVCR120.dll
Report Id: 7dd1f81d-24b7-4627-b779-c823e5f4703a
Faulting package full name:
Faulting package-relative application ID:

Here is the code:

Dim rpt As AccpacCOMAPI.AccpacReport
Dim rptPrintSetup As AccpacCOMAPI.AccpacPrintSetup

Set rpt = mDBLinkCmpRW.Session.ReportSelect("ARDINVO[C:\Temp\Reports\InvoiceReport.rpt]", " ", " ")

Set rptPrintSetup = mDBLinkCmpRW.Session.GetPrintSetup(" ", " ")
rptPrintSetup.DeviceName = "Adobe PDF"
rptPrintSetup.OutputName = "Documents\*.pdf"
rptPrintSetup.Orientation = 1
rptPrintSetup.PaperSize = 1
rptPrintSetup.PaperSource = 15
rpt.PrinterSetup rptPrintSetup
rpt.SetParam "SELECTBY", "1" ' Report parameter: 9
rpt.SetParam "FROMCUST", " " ' Report parameter: 0
rpt.SetParam "TOCUST", "ZZZZZZZZZZZZ" ' Report parameter: 0
rpt.SetParam "FROMDOCNBR", " " ' Report parameter: 0
rpt.SetParam "TODOCNBR", "ZZZZZZZZZZZZZZZZZZZZZZ" ' Report parameter: 0
rpt.SetParam "FCURNDEC", "2" ' Report parameter: 0
rpt.SetParam "ADDR01", "123 Sample Company Plaza" ' Report parameter: 2
rpt.SetParam "ADDR02", " " ' Report parameter: 3
rpt.SetParam "ADDR03", " " ' Report parameter: 4
rpt.SetParam "ADDR04", " " ' Report parameter: 5
rpt.SetParam "CITY", "Any City" ' Report parameter: 6
rpt.SetParam "STATE", "Any Province" ' Report parameter: 7
rpt.SetParam "POSTAL", "12345" ' Report parameter: 8
rpt.SetParam "PRTOPER", "=" ' Report parameter: 0

rpt.SetParam "@SELECTION_CRITERIA", "{ARIBH.CNTBTCH} in " & CStr(Range("BatchNbr").Value) & " to " & CStr(Range("BatchNbr").Value) & " and {ARIBH.CNTITEM} in " & CStr(Range("EntryNbr").Value) & " to " & CStr(Range("EntryNbr").Value) & " and {ARIBH.ERRBATCH} = 0 and {ARIBH.ERRENTRY} = 0 and ({ARIBH.SWPRTINVC} = 1 or {ARIBH.SWPRTINVC} = 0) and {ARCUS.DELMETHOD} = 2 and {ARCUS.CATEGORY} = 0 " ' Report parameter: 0

rpt.SetParam "FROMBATCH", CStr(Range("BatchNbr").Value) ' Report parameter: 0
rpt.SetParam "TOBATCH", CStr(Range("BatchNbr").Value) ' Report parameter: 0
rpt.SetParam "FROMENTRY", CStr(Range("EntryNbr").Value) ' Report parameter: 0
rpt.SetParam "TOENTRY", CStr(Range("EntryNbr").Value) ' Report parameter: 0
rpt.NumOfCopies = 1
rpt.Destination = PD_FILE
rpt.Format = PF_PDF
rpt.PrintDir = Range("InvoicePath").Value & "\Invoices\" & Selection.Offset(0, 7)
rpt.PrintReport            <-- This is where it crashes

Thank you

  • 0
    Maybe confirm that all of the paths are valid, that any existing files are not present and that you have full rights to the output directory (keeping in mind that Excel could be running under a different security context when compared to Sage).
  • SUGGESTED
    In addition to Django's suggestions, make sure you copy the a4wcrInterop.dll from the Runtime directory and place a copy in the folder where your macro lives.
  • SUGGESTED
    In addition to Django's suggestions, make sure you copy the a4wcrInterop.dll from the Runtime directory and place a copy in the folder where your macro lives.
  • 0 in reply to Django
    Thank you for the reply. I checked all paths, even duplicated everything identical to my laptop, with no luck. User has full rights to the output folder as well. I can print to PDF from within ACCPAC, but from Excel using the COM API it fails at that point.
  • Thanks, I will check that out and see if it works.
  • 0 in reply to Shane - Ascend Business Solutions
    That's not going to make any difference.
  • 0
    Try running to preview first to test if it is a Crystal printing issue or a PDF file create issue.
  • 0

    This is code that I use to print a PO.  Try removing the device name and output name from your Print Setup object.

    160       Set rpt = aSession.ReportSelect("POPOR01[" & aCrystalReport & "]", "      ", "      ")
              
    170       Set rptPrintSetup = aSession.GetPrintSetup("      ", "      ")
    180       rptPrintSetup.Orientation = 10
    190       rptPrintSetup.PaperSize = 300
    200       rptPrintSetup.PaperSource = 15
    210       rpt.PrinterSetup rptPrintSetup

    220       rpt.SetParam "PORFROM", aPONo
    230       rpt.SetParam "PORTO", aPONo
    240       rpt.SetParam "ACTIVE", "1"               ' Report parameter: 6
    250       rpt.SetParam "BLANKET", "1"              ' Report parameter: 9
    260       rpt.SetParam "FUTURE", "1"               ' Report parameter: 8
    270       rpt.SetParam "STANDING", "1"             ' Report parameter: 7
    280       rpt.SetParam "PRINTED", "1"              ' Report parameter: 4
    290       rpt.SetParam "DPRINTED", "1"             ' Report parameter: 10
    300       rpt.SetParam "ECENABLED", "0"            ' Report parameter: 12
    310       rpt.SetParam "DIRECTEC", "0"             ' Report parameter: 13
    320       rpt.SetParam "DELMETHOD", "1"            ' Report parameter: 11
    330       rpt.SetParam "SORTFROM", aPONo
    340       rpt.SetParam "SORTTO", aPONo
    350       rpt.SetParam "SWDELMETHOD", "3"          ' Report parameter: 14
    360       rpt.SetParam "QTYDEC", "0"               ' Report parameter: 5
    370       rpt.SetParam "@SELECTION_CRITERIA", "({POPORH1.PONUMBER} = """ & aPONo & """) AND ({POPORH1.ONHOLD} = 0) AND ({POPORL.COMPLETION} = 1) AND (({POPORH1.PORTYPE} = 1) OR ({POPORH1.PORTYPE} = 2) OR ({POPORH1.PORTYPE} = 3) OR ({POPORH1.PORTYPE} = 4))"   ' Report parameter: 0
    380       rpt.NumOfCopies = 1
    390       rpt.Format = PF_PDF
    400       rpt.Destination = PD_FILE
    410       rpt.PrintDir = ini_DocOutputFolder & SourceOrder & " PO-" & aPONo & ".pdf"
    530       rpt.PrintReport

  • 0 in reply to Django
    Just an update, I'm still trying to resolve this issue. One difference is that the client is running the programs from their server, not installed locally on the workstation. I'm not sure if that could be contributing to the problem. I'm trying to replicate the issue on my laptop, but still no success.
  • 0 in reply to Bob Beaucage
    In the client environment, I used a test workstation, and installed the programs locally, instead of via the workstation setup (WSSETUP). The macro and Excel did not crash when Sage 300 is installed locally. I then uninstalled Sage 300, and reinstalled via workstation setup, and the macro and Excel crashed again.

    Another note, when Sage 300 was first installed locally, with no Product Updates installed (i.e. Build 0), the ACCPAC desktop was crashing when Sage 300 was launched, and the faulting module was also MSVCR120.dll. I then installed Product Update 2 (Build 20), and Sage 300 launched successfully, and the macro ran fine in Excel.

    That still does not explain why Excel crashes with the programs running from the server. I used PROCMON to try and diagnose the problem, and installed and reinstalled the Visual C++ Redistributable, all with no success.
  • 0 in reply to Bob Beaucage
    The final workaround was to install the System Manager only, locally, then repoint the registry entry for programs back to the server share, install the workstation setup, and the macro runs fine.

    Something in the SM install is missing in the WSSETUP, and allows the macro to work, but still not sure what that is.