Hello,
I'am trying to write some VBA code to print several drawings present in a folder.
I am not a VBA expert. I wrote some little macros in excel but it is the first one in Autocad.
I have a small code that opens a drawing, counts it, closes it and then loops for other drawings.
I have a code that print a drawing by defining some printing parameters.
Separetely, both work.
But when I call the second one into the loop, I get a error:
"Run-time error '-2147418111 (800100001)':
Automation error
Call was rejected by callee."
The help about this error doesn't help me...
Could anyone please help me with that ?
Thank you very much.
I'm using Windows 7 and Autocad 2012.
See my code below:
Option Explicit
Dim filename As String
Dim filepath As String
Dim full_filename As String
Dim i As Integer
Sub print_trial()
filepath = "D:\Home\Drawings\"
filename = Dir(filepath & "*.dwg")
i = 0
Do While Len(filename) > 0
ThisDrawing.Application.Documents.Open (filepath & filename), False
ThisDrawing.ActiveLayout.ConfigName = "\\AMSTERDAM\x7545b"
ThisDrawing.ActiveLayout.CanonicalMediaName = "A3"
ThisDrawing.ActiveLayout.UseStandardScale = True
ThisDrawing.ActiveLayout.StandardScale = acScaleToFit
ThisDrawing.ActiveLayout.PlotRotation = ac90degrees
ThisDrawing.ActiveLayout.PlotType = acExtents
ThisDrawing.ActiveLayout.StyleSheet = "monochrome.ctb"
ThisDrawing.Plot.NumberOfCopies = 1
ThisDrawing.Plot.PlotToDevice
ThisDrawing.Application.ActiveDocument.Close
i = i + 1
filename = Dir()
Loop
MsgBox i
End Sub