hi all i`m created code with vba to export 10 sheets from model to pdf`s but everytimes had error with line
result = ThisDrawing.Plot.PlotToFile(plotFileName)can you help me to solve problem?
Sub PlotMultipleSheetsByPoints()
Dim Layout As AcadLayout
Dim pt1(0 To 1) As Double
Dim pt2(0 To 1) As Double
Dim plotFileName As String
Dim i As Integer
Dim OffsetX As Double
Dim result As Boolean
Set Layout = ThisDrawing.ActiveLayout
Layout.RefreshPlotDeviceInfo
Layout.ConfigName = "DWG to PDF.pc3"
Layout.CanonicalMediaName = "ISO_full_bleed_A3_(420.00_x_297.00_MM)"
Layout.CenterPlot = True
Layout.PlotRotation = ac0degrees
Layout.StandardScale = asScaleToFit
Layout.StyleSheet = "acad.ctb"
Layout.PlotType = acWindow
' based coords
pt1(1) = 0# ' Y1
pt2(1) = 297# ' Y2
OffsetX = 420# ' weigh sheets
' plot 10 sheets
For i = 1 To 10
plotFileName = "C:\Users\user\Desktop\autoPDF\" & i & ".pdf"
' offset for every sheets
pt1(0) = (i - 1) * OffsetX ' X1
pt2(0) = pt1(0) + OffsetX + 50 ' X2
' set window to plot
Layout.SetWindowToPlot pt1, pt2
' regen and plot
ThisDrawing.Regen acAllViewports
result = ThisDrawing.Plot.PlotToFile(plotFileName)
Next i
End Sub
Solved! Go to Solution.
Solved by norman.yuan. Go to Solution.
Have you stepped through the code to see if all the variables are being set as expected? Is the file path really "C:\Users\user\Desktop\autoPDF"? I assume the 'user' is properly set to your profile name?
yeah, this pc have user name - user.
I changed this to
plotFileName = "D:\autopdf\" & i & ".pdf"and this still don`t working. I also forgot to add scrin error
and after click debug
Sorry accidently clicked "Accept Solution" button.
You may want to try to disable background plotting by setting "BackgroundPlot" system variable to 0 (and restore it back after your coded plotting.
Can't find what you're looking for? Ask the community or share your knowledge.