<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Automated print from VBA using a saved page setup in VBA Forum</title>
    <link>https://forums.autodesk.com/t5/vba-forum/automated-print-from-vba-using-a-saved-page-setup/m-p/2250527#M19858</link>
    <description>I have one problem. Looks like this method plots to plt file, but with .pdf extension. I'm unable to open it in Adobe Acrobat.&lt;BR /&gt;
Also, the file is approx. 700 kB.&lt;BR /&gt;
The same drawing, with the same settings (set programatically), but plotted manually, using PLOT command, is OK and weights approx. 170 kB.&lt;BR /&gt;
Any suggestions?</description>
    <pubDate>Mon, 25 Jan 2010 17:48:59 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2010-01-25T17:48:59Z</dc:date>
    <item>
      <title>Automated print from VBA using a saved page setup</title>
      <link>https://forums.autodesk.com/t5/vba-forum/automated-print-from-vba-using-a-saved-page-setup/m-p/2250520#M19851</link>
      <description>Hi all..&lt;BR /&gt;
&lt;BR /&gt;
i have a small program in VBA where i run some procedures .&lt;BR /&gt;
&lt;BR /&gt;
The program reads in the files i select and then work from that.&lt;BR /&gt;
&lt;BR /&gt;
I want to add an automatic plot to PDF function, but i'm struggling a bit to get the syntaxes right. I have tried it with some send commands and it works but i'd want to do it properly using VBA.&lt;BR /&gt;
&lt;BR /&gt;
Anyways, this is roughly what i'd want to do:&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
(my program already opens every drawing automatic in sequence)&lt;BR /&gt;
&lt;BR /&gt;
-( drawing is opened)&lt;BR /&gt;
&lt;BR /&gt;
-copy page setup from one file i have saved/manually enter the plot styles. ( i want to use the DWGToPDF.pc3 config)&lt;BR /&gt;
&lt;BR /&gt;
-print file&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Anyone have any code/ideas for this? any help would be appreciated...&lt;BR /&gt;
&lt;BR /&gt;
-(close drawing) and then loop</description>
      <pubDate>Thu, 08 May 2008 11:58:45 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/automated-print-from-vba-using-a-saved-page-setup/m-p/2250520#M19851</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2008-05-08T11:58:45Z</dc:date>
    </item>
    <item>
      <title>Re: Automated print from VBA using a saved page setup</title>
      <link>https://forums.autodesk.com/t5/vba-forum/automated-print-from-vba-using-a-saved-page-setup/m-p/2250521#M19852</link>
      <description>Hi Takstein.&lt;BR /&gt;
&lt;BR /&gt;
I believe what you need to do is to use the Plot Object of autocad, and add a new plot configuration which uses DWGToPDF.pc3, and then use the PlotToFile method to create the pdf.&lt;BR /&gt;
&lt;BR /&gt;
here is some code I did in Delphi, but I hope you can adapt it to your VBA code.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Procedure CreatePDF(Dwg : String  );&lt;BR /&gt;
Var&lt;BR /&gt;
PtConfigs : AcadplotConfigurations;&lt;BR /&gt;
PlotConfig : AcadPlotConfiguration;&lt;BR /&gt;
PtObj : AcadPlot;&lt;BR /&gt;
BackPlot : olevariant;&lt;BR /&gt;
&lt;BR /&gt;
begin&lt;BR /&gt;
//Create a new plot configutrarion with all needed parameters&lt;BR /&gt;
PtObj:= ThisDrawing.Plot; '&lt;BR /&gt;
PtConfigs:= ThisDrawing.PlotConfigurations;&lt;BR /&gt;
PtConfigs.Add('PDF',false);{Here is where you add a new plot configuration}&lt;BR /&gt;
&lt;BR /&gt;
plotConfig:= PtConfigs.Item('PDF');{the plot config you created become active}&lt;BR /&gt;
plotConfig.StandardScale := acScaleToFit;{use this method to set the scale}&lt;BR /&gt;
&lt;BR /&gt;
plotconfig.RefreshPlotDeviceInfo;&lt;BR /&gt;
&lt;BR /&gt;
plotconfig.ConfigName:='DWG To PDF.pc3';{here you specify the pc3 file you want to use}&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
PlotConfig.StyleSheet:='Acad.ctb';{you can select the plot style table here}&lt;BR /&gt;
PlotConfig.PlotWithPlotStyles:=True;&lt;BR /&gt;
&lt;BR /&gt;
{If you are ging to create pdf files in a batch mode, i would recommend to turn off the BACKGROUNDPLOT system variable, so autocad will not continue to do anything until finishes the pdf craetion}&lt;BR /&gt;
BackPlot:= ThisDrawing.GetVariable('BACKGROUNDPLOT');&lt;BR /&gt;
Acad.ActiveDocument.SetVariable('BACKGROUNDPLOT',0);&lt;BR /&gt;
plotconfig.RefreshPlotDeviceInfo;&lt;BR /&gt;
{Now you can use the PlotTofile method}&lt;BR /&gt;
if PtObj.PlotToFile('DwgName.pdf' ,plotConfig.ConfigName) then&lt;BR /&gt;
showmessage('PDF Was Created')&lt;BR /&gt;
else&lt;BR /&gt;
showmessage('PDF Creation Unsuccessful');&lt;BR /&gt;
&lt;BR /&gt;
{If you wish you can delete th plot configuration you created programmatically, and set the 'BACKGROUNDPLOT' system variable to its original status.&lt;BR /&gt;
&lt;BR /&gt;
PtConfigs.Item('PDF').Delete;&lt;BR /&gt;
Acad.ActiveDocument.SetVariable('BACKGROUNDPLOT',BackPlot); &lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
It is important to remember putting the extension".pdf" to the name of the file you create using the plot to file method.&lt;BR /&gt;
&lt;BR /&gt;
Hope this helped.&lt;BR /&gt;
&lt;BR /&gt;
Regards.&lt;BR /&gt;
&lt;BR /&gt;
Mario</description>
      <pubDate>Sun, 11 May 2008 23:57:19 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/automated-print-from-vba-using-a-saved-page-setup/m-p/2250521#M19852</guid>
      <dc:creator>Mario-Villada</dc:creator>
      <dc:date>2008-05-11T23:57:19Z</dc:date>
    </item>
    <item>
      <title>Re: Automated print from VBA using a saved page setup</title>
      <link>https://forums.autodesk.com/t5/vba-forum/automated-print-from-vba-using-a-saved-page-setup/m-p/2250522#M19853</link>
      <description>Thanks, Mario&lt;BR /&gt;
Worked like a charm for me (A2008)&lt;BR /&gt;
&lt;BR /&gt;
Here is VBA version:&lt;BR /&gt;
&lt;BR /&gt;
Option Explicit&lt;BR /&gt;
&lt;BR /&gt;
Sub CreatePDF()&lt;BR /&gt;
&lt;BR /&gt;
Dim PtConfigs As AcadPlotConfigurations&lt;BR /&gt;
Dim PlotConfig As AcadPlotConfiguration&lt;BR /&gt;
Dim PtObj As AcadPlot&lt;BR /&gt;
Dim BackPlot As Variant&lt;BR /&gt;
&lt;BR /&gt;
'Create a new plot configutrarion with all needed parameters&lt;BR /&gt;
Set PtObj = ThisDrawing.Plot&lt;BR /&gt;
Set PtConfigs = ThisDrawing.PlotConfigurations&lt;BR /&gt;
'Add a new plot configuration&lt;BR /&gt;
PtConfigs.Add "PDF", False&lt;BR /&gt;
'The plot config you created become active&lt;BR /&gt;
Set PlotConfig = PtConfigs.Item("PDF")&lt;BR /&gt;
'Use this method to set the scale&lt;BR /&gt;
PlotConfig.StandardScale = acScaleToFit&lt;BR /&gt;
'Updates the plot&lt;BR /&gt;
PlotConfig.RefreshPlotDeviceInfo&lt;BR /&gt;
'Here you specify the pc3 file you want to use&lt;BR /&gt;
PlotConfig.ConfigName = "DWG To PDF.pc3"&lt;BR /&gt;
'You can select the plot style table here&lt;BR /&gt;
PlotConfig.StyleSheet = "Acad.ctb"&lt;BR /&gt;
'Specifies whether or not to plot using the plot styles&lt;BR /&gt;
PlotConfig.PlotWithPlotStyles = True&lt;BR /&gt;
&lt;BR /&gt;
'If you are going to create pdf files in a batch mode,&lt;BR /&gt;
'I would recommend to turn off the BACKGROUNDPLOT system variable,&lt;BR /&gt;
'so autocad will not continue to do anything until finishes&lt;BR /&gt;
'the pdf creation&lt;BR /&gt;
BackPlot = ThisDrawing.GetVariable("BACKGROUNDPLOT")&lt;BR /&gt;
ThisDrawing.SetVariable "BACKGROUNDPLOT", 0&lt;BR /&gt;
'Updates the plot&lt;BR /&gt;
PlotConfig.RefreshPlotDeviceInfo&lt;BR /&gt;
'Now you can use the PlotTofile method&lt;BR /&gt;
If PtObj.PlotToFile(Replace(ThisDrawing.FullName, "dwg", "pdf"), PlotConfig.ConfigName) Then&lt;BR /&gt;
MsgBox "PDF Was Created"&lt;BR /&gt;
Else&lt;BR /&gt;
MsgBox "PDF Creation Unsuccessful"&lt;BR /&gt;
End If&lt;BR /&gt;
'If you wish you can delete th plot configuration you created&lt;BR /&gt;
'programmatically, and set the 'BACKGROUNDPLOT' system variable&lt;BR /&gt;
'to its original status.&lt;BR /&gt;
PtConfigs.Item("PDF").Delete&lt;BR /&gt;
Set PlotConfig = Nothing&lt;BR /&gt;
ThisDrawing.SetVariable "BACKGROUNDPLOT", BackPlot&lt;BR /&gt;
&lt;BR /&gt;
End Sub&lt;BR /&gt;
&lt;BR /&gt;
~'J'~</description>
      <pubDate>Mon, 12 May 2008 16:27:34 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/automated-print-from-vba-using-a-saved-page-setup/m-p/2250522#M19853</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2008-05-12T16:27:34Z</dc:date>
    </item>
    <item>
      <title>Re: Automated print from VBA using a saved page setup</title>
      <link>https://forums.autodesk.com/t5/vba-forum/automated-print-from-vba-using-a-saved-page-setup/m-p/2250523#M19854</link>
      <description>Hi all, I have made a program following the codes above using C#. But in my code, the plotconfiguration does not work. The program do created a new pagesetup, but it's not selected when plotting. is there any method to set a plotconfiguration to be active when plotting?&lt;BR /&gt;
&lt;BR /&gt;
Thanks,Eric</description>
      <pubDate>Thu, 15 Jan 2009 11:40:51 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/automated-print-from-vba-using-a-saved-page-setup/m-p/2250523#M19854</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2009-01-15T11:40:51Z</dc:date>
    </item>
    <item>
      <title>Re: Automated print from VBA using a saved page setup</title>
      <link>https://forums.autodesk.com/t5/vba-forum/automated-print-from-vba-using-a-saved-page-setup/m-p/2250524#M19855</link>
      <description>HI Fatty&lt;BR /&gt;
 what's the BACKGROUNDPLOT system variable in your code?. &lt;BR /&gt;
 i copied your code and trying in my my application it gives error.</description>
      <pubDate>Tue, 03 Feb 2009 10:20:53 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/automated-print-from-vba-using-a-saved-page-setup/m-p/2250524#M19855</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2009-02-03T10:20:53Z</dc:date>
    </item>
    <item>
      <title>Re: Automated print from VBA using a saved page setup</title>
      <link>https://forums.autodesk.com/t5/vba-forum/automated-print-from-vba-using-a-saved-page-setup/m-p/2250525#M19856</link>
      <description>Thats exactly why i'm here today!&lt;BR /&gt;
AcadPlotConfigurations dosen't seem to have a method that 'set current' the selected PlotConfig.&lt;BR /&gt;
if u managed to find a way to do it, please let me know.</description>
      <pubDate>Sat, 14 Mar 2009 10:38:58 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/automated-print-from-vba-using-a-saved-page-setup/m-p/2250525#M19856</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2009-03-14T10:38:58Z</dc:date>
    </item>
    <item>
      <title>Re: Automated print from VBA using a saved page setup</title>
      <link>https://forums.autodesk.com/t5/vba-forum/automated-print-from-vba-using-a-saved-page-setup/m-p/2250526#M19857</link>
      <description>I had that problem too and I solve it by using copyfrom method.&lt;BR /&gt;
 just insert this line before calling the PlotToFile Method.&lt;BR /&gt;
{code}&lt;BR /&gt;
Acad.ActiveDocument.ActiveLayout.CopyFrom(plotconfig) &lt;BR /&gt;
{code}&lt;BR /&gt;
&lt;BR /&gt;
Sorry guys for the late response but  I did not get any warning from autodesk that someone wrote a reply.&lt;BR /&gt;
&lt;BR /&gt;
I hope at least this help someone else in the future&lt;BR /&gt;
&lt;BR /&gt;
regards,&lt;BR /&gt;
&lt;BR /&gt;
Mario.</description>
      <pubDate>Tue, 20 Oct 2009 04:40:08 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/automated-print-from-vba-using-a-saved-page-setup/m-p/2250526#M19857</guid>
      <dc:creator>Mario-Villada</dc:creator>
      <dc:date>2009-10-20T04:40:08Z</dc:date>
    </item>
    <item>
      <title>Re: Automated print from VBA using a saved page setup</title>
      <link>https://forums.autodesk.com/t5/vba-forum/automated-print-from-vba-using-a-saved-page-setup/m-p/2250527#M19858</link>
      <description>I have one problem. Looks like this method plots to plt file, but with .pdf extension. I'm unable to open it in Adobe Acrobat.&lt;BR /&gt;
Also, the file is approx. 700 kB.&lt;BR /&gt;
The same drawing, with the same settings (set programatically), but plotted manually, using PLOT command, is OK and weights approx. 170 kB.&lt;BR /&gt;
Any suggestions?</description>
      <pubDate>Mon, 25 Jan 2010 17:48:59 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/automated-print-from-vba-using-a-saved-page-setup/m-p/2250527#M19858</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2010-01-25T17:48:59Z</dc:date>
    </item>
    <item>
      <title>Re: Automated print from VBA using a saved page setup</title>
      <link>https://forums.autodesk.com/t5/vba-forum/automated-print-from-vba-using-a-saved-page-setup/m-p/2250528#M19859</link>
      <description>Are you using DWG To PDF.pc3 as your plotter? (plotconfig.ConfigName). If you use a different printer it migh not work, unless that printer has a driver capable of making pdfs. &lt;BR /&gt;
&lt;BR /&gt;
And please don't forget to add this line:&lt;BR /&gt;
{code}&lt;BR /&gt;
Acad.ActiveDocument.ActiveLayout.CopyFrom(plotconfig)&lt;BR /&gt;
{code}&lt;BR /&gt;
&lt;BR /&gt;
just before calling the PlotToFile method. otherwise you woud be using the last plot configuration saved in the drawing.&lt;BR /&gt;
hope this helps.</description>
      <pubDate>Wed, 27 Jan 2010 05:08:20 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/automated-print-from-vba-using-a-saved-page-setup/m-p/2250528#M19859</guid>
      <dc:creator>Mario-Villada</dc:creator>
      <dc:date>2010-01-27T05:08:20Z</dc:date>
    </item>
    <item>
      <title>Re: Automated print from VBA using a saved page setup</title>
      <link>https://forums.autodesk.com/t5/vba-forum/automated-print-from-vba-using-a-saved-page-setup/m-p/2908244#M19860</link>
      <description>&lt;P&gt;If I add the code below:&lt;/P&gt;&lt;P&gt;Acad.ActiveDocument.ActiveLayout.CopyFrom(plotconfig)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;it gives an error on that code, if i dont add that code it gives an error on the "Plotfile method"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;"Object doesnt support this property or method"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;any idea what teh reason can be?&lt;/P&gt;</description>
      <pubDate>Tue, 08 Feb 2011 12:34:41 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/automated-print-from-vba-using-a-saved-page-setup/m-p/2908244#M19860</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2011-02-08T12:34:41Z</dc:date>
    </item>
  </channel>
</rss>

