0

Hi how can I Plot to Pdf my AutoCAD drawing using VBA? I Tried

Sub PlotToPdf()
ThisDrawing.ActiveLayout.ConfigName = "DWF6 ePlot.pc3"
Dim plotFileName As String
plotFileName = "Z:\USERS\KweziM\PROJECT S\MyPlot.pdf"

Dim result As Boolean

result = ThisDrawing.Plot.PlotToFile(plotFileName)
End Sub

But this does not work.

braX
  • 11,506
  • 5
  • 20
  • 33
K Bizzy
  • 85
  • 1
  • 13

2 Answers2

1

That last line should be a subroutine call, not a function call... it should look like this

ThisDrawing.Plot.PlotToFile plotFileName

You do not need the result variable.

braX
  • 11,506
  • 5
  • 20
  • 33
0

try this:

Public Sub VBAplot()
    Dim currentplot As AcadPlot
    Set currentplot = ThisDrawing.Plot

    ThisDrawing.ActiveLayout.ConfigName = "PDFCreator" ' Your plot device.
    ThisDrawing.ActiveLayout.CanonicalMediaName = "A4"

    ThisDrawing.ActiveLayout.StandardScale = acScaleToFit
    ThisDrawing.Application.ZoomExtents
    currentplot.PlotToDevice


End Sub
CAD Developer
  • 1,532
  • 2
  • 21
  • 27
  • Thanks but this gives me an "invalid input" error on line 4 of the code.`ThisDrawing.ActiveLayout.ConfigName = "PDFCreator"` – K Bizzy Nov 22 '17 at 14:31
  • PDFCreator is the external application. Virtual PDF Plotter. I suppose You don' have installed it. so You should use some other PDF plotter or "pc3" configuration file. – CAD Developer Nov 22 '17 at 14:53
  • 1
    In AutoCAD You have few build-in drivers to save to PDF like "DWG To PDF.pc3" "AutoCad PDF (General Documentation).pc3" "AutoCad PDF (High Quality Print).pc3" use one of them – CAD Developer Nov 23 '17 at 12:12