VBA
Discuss AutoCAD ActiveX and VBA (Visual Basic for Applications) questions here.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Plot multiple drawings using VBA

2 REPLIES 2
Reply
Message 1 of 3
AF_DI
2862 Views, 2 Replies

Plot multiple drawings using VBA

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

2 REPLIES 2
Message 2 of 3
norman.yuan
in reply to: AF_DI

Try to turn off background plotting before running the code.

 

Norman Yuan

Drive CAD With Code

EESignature

Message 3 of 3
AF_DI
in reply to: norman.yuan

Thank you for the reply.

 

Unfortunately it didn't change anything...

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost