- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I write code for plot all dwg of project to pdf. But code con't create all pdf of project .Received an incomplete pdf file. Plase help me.
This my code . Sub ReadFileForPlotToPdf for Read dwg file of project and Sub PlotThisFileToPdf for plot pdf
Sub ReadFileForPlotToPdf()
Dim configName As String
Dim mediaName As String
Dim plotRotation As Integer
Dim plotType As Integer
Dim scaleSheet As Integer
Dim styleSheet As String
Dim plotWithStyles As Boolean
Dim plotHidden As Boolean
Dim plotViewportsFirst As Boolean
With ThisDrawing.ActiveLayout
configName = .configName
mediaName = .CanonicalMediaName
plotRotation = .plotRotation
plotType = .plotType
scaleSheet = .StandardScale
styleSheet = .styleSheet
plotWithStyles = .PlotWithPlotStyles
plotHidden = .plotHidden
plotViewportsFirst = .plotViewportsFirst
End With
Dim folderPath As String
folderPath = ThisDrawing.Path
Dim File As String
File = Dir(folderPath & "\*.dwg")
Dim FullFilename As String
Do While File <> ""
FullFilename = folderPath & "\" & File
If FullFilename <> ThisDrawing.FullName Then
ThisDrawing.Application.Documents.Open (FullFilename)
With ThisDrawing.ActiveLayout
.configName = configName
.CanonicalMediaName = mediaName
.CenterPlot = True
.plotRotation = plotRotation
.plotType = plotType
.StandardScale = scaleSheet
.styleSheet = styleSheet
.PlotWithPlotStyles = plotWithStyles
.plotHidden = plotHidden
.plotViewportsFirst = plotViewportsFirst
End With
'Save plot style
ThisDrawing.Save
'Plot thisdrawing to pdf
PlotThisFileToPdf
ThisDrawing.Close False
Else
'Plot file type to pdf
PlotThisFileToPdf
End If
File = Dir
If Emergency Then
File = ""
End If
Loop
End Sub
Sub PlotThisFileToPdf()
Dim File As String
File = ThisDrawing.FullName
Dim plotFileName As String
plotFileName = Left(File, Len(File) - 4) & ".pdf"
Dim result As Boolean
On Error Resume Next
result = ThisDrawing.plot.PlotToFile(plotFileName)
On Error GoTo 0
If result Then
Debug.Print Format(Now, "hh-nn-ss") & " PDF generated successfully for: " & GetFileName(plotFileName)
Else
Debug.Print Format(Now, "hh-nn-ss") & " Plot failed for: " & GetFileName(plotFileName)
End If
End Sub
Thank you.
Solved! Go to Solution.