View Full Version : Print Previous

2004-09-15, 10:59 PM
Hi all,

Just wonder how to "print pervous". I know there is a "ThisDrawing.PrintPrevious" But I cant get it to work. I get the following error.

Run-time error '28'
out of stack space

Thanks for your help.

AutoCAD 2005

Ed Jobe
2004-09-17, 02:37 PM
Oh, that's not good! :-) Show some code so we can see what might be generating tha error. Provide as much background detail as you can when trying to diagnose a problem.

2004-09-17, 03:29 PM
It's not much to look at but here it is.

Public Sub PrintPrevious()

End Sub

Ed Jobe
2004-09-17, 03:57 PM
It says a whole lot. "PrintPrevious" is not an acad procedure. If you look in the Object Browser, you will find that there is no object, property or method called PrintPrevious. If I type it in my immediate window, I get "procedure not defined". Where it *is* defined is in the sub you just posted and it is calling itself over and over and over again...until you run out of memory, i.e. "stack space".

There is however, a PlotConfiguration (aka named page setup) with the "name", "Previous Plot". To set it to the active page setup, you can use:
ThisDrawing.ActiveLayout.Copyfrom (ThisDrawing.PlotConfigurations("Previous Plot"))
Then you can plot the active layout.

2004-09-17, 10:05 PM
Thanks for taking the time to answer my question.


2004-09-20, 07:18 PM
I tried what you suggested and this is the error that I got.

Run-time error ‘-2145386476 (80200014)’:

Key not found

Is there something else that I need to do. From what I can tell you can't set the configuration to <None> or <Previous plot> only to custom setups.

AutoCAD 2005

Ed Jobe
2004-09-20, 07:38 PM
Sorry about that. That wasn't tested code. I just threw it out there. Now I remember that, although you see "Previous Plot" in the combo box on the Page Setup form, its not a true PlotConfiguration object. In order to store the setting across sessions and across dwgs, it is stored in the registry. Here is the key where you could copy the settings to the ActiveLayout.
HKEY_CURRENT_USER\Software\Autodesk\AutoCAD\R15.0\ACAD-2:409\Profiles\PlainAcad\Previous plot settings. There are two key here, for "Model" and "Layout" setups.

2004-09-20, 07:54 PM
Never tired to access the registry from VBA is there a quick references somewhere I could go off of?

Ed Jobe
2004-09-20, 08:14 PM
You need to use the win api. Microsoft has regobj.dll (http://msdn.microsoft.com/vbasic/downloads/addins/components/default.aspx) you could download that provided some function wrappers for this. I just create a class module in my project that has just the functions I need. Some of it is from vbdesign.net, which is now cadvault.com (http://www.cadvault.com/index.php?page=code&cats=32&view=137)

2004-09-22, 05:29 PM
OK I can now read from the registry 8) :

Just so I understand correctly my next step would be to take all of the 34 some odd registry values and apply them individually to the current layout thus making the plot configuration mimic the previous plot.

Would I need to create a temporary plot config and then set those values to it?

Any suggestions as to my next step would be appreciated.