AnsweredAssumed Answered

edrawings api on finished loading

Question asked by Joel Seerey on May 20, 2020
Latest reply on May 25, 2020 by Joel Seerey

I am creating an excel spreadsheet to print drawing files using edrawings. I have been able to get the file to load and print as intended while debugging and stepping through the code, when letting it run at full speed it crashes due to attempting to print before the file is loaded.


my plan is to use the OnFinishedLoadingDocumentEventHandler after the opendoc command but i cant figure out how to add this to the code in a way that it will function. can anybody help me to implement this feature? thanks.

code is in VBA



Private Sub CommandButton1_Click()

Set prtlst = ThisWorkbook.Worksheets("Sheet1").ListObjects("Table1")
   Dim prtLoc As Range: Set prtLoc = prtlst.Range(2, 1)
     Dim rowCnt As Integer: rowCnt = 0
     Dim partno As String
     Dim path As String
     filepath = Range("SAVE").Value
      Dim printer As String
    printer = Application.ActivePrinter
    printer = Left(printer, InStr(printer, " on") - 1)
   ' "\\UTIL\RD4DRU (HP LaserJet MFP M725)"
    Do While Not IsEmpty(prtLoc.Offset(rowCnt, 0).Value)
     partno = prtLoc.Offset(rowCnt, 0).Value
     path = prtLoc.Offset(rowCnt, 4).Value

EMVControls.OpenDoc path, True, True, True, ""

EMVControls.SetPageSetupOptions EMVPrintOrientation.eLandscape, 1, 0, 0, 1, 7, printer, 0, 0, 0, 0

EMVControls.Print5 False, partno, False, False, False, EMVPrintType.eScaleToFit, 0, 0, 0, True, 0, 0, ""
'print file
' close doc
EMVControls.CloseActiveDoc ""

rowCnt = rowCnt + 1
End Sub