Message 1 of 7
Why does my VBA function generate a blank PDF for one DWG file but work fine for another?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I have a VBA Excel function that plots a selected area to PDF using DWG To PDF.pc3. The function works correctly for one DWG file, generating a properly formatted PDF, but when I run it on another DWG file (with the same settings and details), the resulting PDF is blank.
Here is my function:
Function TestPlotSelectedAreaToPdf() As Boolean
On Error GoTo ErrorHandler
acadDoc.SetVariable "BACKGROUNDPLOT", 0
Dim plotFileName As String
plotFileName = "D:\Test\TestPlotSelectedArea.pdf"
Dim lowerLeft(0 To 1) As Double
Dim upperRight(0 To 1) As Double
lowerLeft(0) = 0#: lowerLeft(1) = 0#
upperRight(0) = 297#: upperRight(1) = 210#
With acadDoc.ActiveLayout
.configName = "Acade - DWG To PDF.pc3"
.CanonicalMediaName = "ISO_full_bleed_A4_(297.00_x_210.00_MM)"
.plotType = acWindow
.SetWindowToPlot lowerLeft, upperRight
.centerPlot = True
.StandardScale = acScaleToFit
.plotRotation = ac0degrees
.PlotWithPlotStyles = True
.RefreshPlotDeviceInfo
End With
acadDoc.Plot.PlotToFile plotFileName
TestPlotSelectedAreaToPdf = True
Exit Function
ErrorHandler:
Debug.Print "Error TestPlotSelectedAreaToPdf : " & Err.Description
TestPlotSelectedAreaToPdf = False
End Function
Additional Info:
- Both DWG files contain similar objects and layers.
- The PDF output for one file is correct, while the other file generates a blank PDF.
- No errors occur during execution.
- File Test1.dwg can ploted to pdf
- File Test2.dwg can ploted to pdf but is blank pdf
What could be causing this issue? Are there any settings in the DWG file that might affect the plot result?