By Daniel Du
Why do I get an error when I try to set the ConfigName of a Layout?
The usual reason for this error is that you are not calling 'RefreshPlotDeviceInfo' before assigning a 'ConfigName'.
Here is an example of some VBA code that does work:
Dim Layouts As AcadLayouts
Dim Layout As AcadLayout
' Get the files preferences object
Set Layouts = ThisDrawing.Layouts
' Change plotter configuration file
Layouts("Model").ConfigName = "PrinterName"
If you comment out the line 'Layout("Model").RefreshPlotDeviceInfo', the routine will work sometimes, but not always.
Please note that you will still generate an error if you try to set a ConfigName that AutoCAD cannot find.