

ReaConverter is quick to download, install and launch, and you don't need to be an IT specialist in order to understand in a few minutes how it operates.
#DWG TO PDF CONVERTER HOW TO#
This software is extremely efficient in managing a wide range of batch conversions.Īs you will soon realize, reaConverter will help you avoid spending countless hours trying to figure out how to convert multiple DWG files as once.Īt the same time, it will allow you to apply a wide range of image editing options during conversion.
#DWG TO PDF CONVERTER CODE#
I tried to comment Set dwg = (fName) the code shows error at = "ANSI_full_bleed_D_(34.00_x_22.00_Inches)" stating invalid input.The quick and simple way to handle your files is to get a quality piece of software, such as reaConverter. In opath and dpath if remove the last backslash(\) of directory the code gives an error at For i = 0 To UBound(fileNames) stating "subscript out of range" if I put backslash it stuck at Set dwg = (fName) saying file not found even though the error has file name which is present in the directory. OPath = "C:\Documents and Settings\Administrator\Desktop\New Folder\"ĭPath = "C:\Documents and Settings\Administrator\Desktop\PDF\" Private Sub PlotToPdf(dwg As AcadDocument, pdfFile As String) ''Get all DWG file from the Original Path ThisDrawing.SetVariable "BACKGROUNDPLOT", backPlot PdfName = dPath & brutName & ".pdf" ''Determine PDF name based on DWG file name ThisDrawing.SetVariable "BACKGROUNDPLOT", 0 There is the final version of the macro for those who need it :īackPlot = ThisDrawing.GetVariable("BACKGROUNDPLOT") I use your solution and adapt it and it work perfectly Sorry for the code block, i didn't see the button ^^ The code is not tested, and is just meant to provide some ideas.

'' Then eventually call AcadPlot.PlotToFile with "pdfFile" as parameter. '' set up correct layout as the active one, set up plot type: layout/extents/window, scale. '' do your plotting work here against the "dwg" object, including Private Sub PlotToPdg(dwg As AcadDocument, pdfFile As String) Private Function GetFileNames(path As String) As String() ThisDrawing.SetSysVariable "BACKGROUNDPLOT" baclPlot PdfName= ''Determine PDF name based on DWG file name ThisDrawing.SetSysVariable "BACKGROUNDPLOT", 0įileNames=GetFileNames("C:\.\dwgFolder") To make the code a bit easier to read/debug, you might to organize it like this: Public Sub DoPdfPlot()īackPlot=ThisDrawing.GetSysVariable("BACKGROUNDPLOT) You do not use an empty "DO.Loop" to wait the background plotting to be finished. That is, you need to set system variable "BACKGROUNDPLOT" to 0 before your code does the plotting (and restore it back to its original value after the plotting is done. Since the code needs to close each drawing after PDF plotting, you need to make sure the plotting is finished before the code in the "While.Wend" loop does the closing, thus, you need to disable background plotting. Error on ĪcadDocuments.Close() closes ALL drawings, not only the drawing you just opened for plotting.ģ. GoTo Line1 'If PDF is not created after x seconds, retryįirstly, please use the "" button on top of the message text box to post code, so that the code is posted in read-able format.Ĭurrentplot.PlotToFile ""īecause you are plotting to PDF file, right? So, you need to supply a desired file path/name here, not to rename the PDF file after plotting (you do not even know where the PDF file is!)Ģ. Name originalPdfFile As destinationPdfFile G_sb_Delay 26 'Waiting until the PDF is created OriginalPdfFile = path & fileName & "-Model.pdf"ĭestinationPdfFile = destinationPath & fileName & ".pdf"


The macro crash at the conversion part at the 2nd DWG.Rename & Move the PDF to another specific directory.Get all the DWG in a specific directory.I have to create a VBA macro for AutoCAD, but I'm not a VBA expert.
