Community
AutoCAD Forum
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Create pdf of dwg file from excel

10 REPLIES 10
Reply
Message 1 of 11
navark
3265 Views, 10 Replies

Create pdf of dwg file from excel

Hi there,

 

I have been looking everywhere but strangely haven't found a way to create a pdf of a dwg from excel.

The idea would be to print specific sheets of a given dwg without having to open it and using the last plot/page setup properties.

 

If you know of any ways to achieve that I would be glad if you could point me in the right direction.

 

Note that I am using Autocad 2014 LT and Excel's VBA.

 

Many thanks for your help.

10 REPLIES 10
Message 2 of 11
rkmcswain
in reply to: navark

Do I understand this correctly?
You want to use Excel to print an AutoCAD drawing?
R.K. McSwain     | CADpanacea | on twitter
Message 3 of 11
navark
in reply to: rkmcswain

Well not far yes!

 

I want to use VBA in excel to control autocad in order to:

1 open a dwg file in the background (that part is easy!)

2 export a sheet as pdf (still in the background)

3 close the file

 

It must be doable I have done similar things on other sofware but for some reason finding any kind documentation on this topic for Acad seems near impossible.

Any help would be greately appreciated!

Message 4 of 11
ampster402
in reply to: navark

I'd recommend a script instead of an excel file.

Message 5 of 11
navark
in reply to: ampster402

Yes sure the only thing is that the pdf creation is just one part of a more complex vba program.

The excel spreadsheet is used as an issue control tool where, when a file is ready to be issued to the customer the current file is moved to an "Issue" folder replacing the previous issue which is moved to an "Historical" folder. (The project history is also tracked within the excel spreadsheet).

Since both dwg and pdf are sent to the customer I need to automate the pdf creation within this excel sheet.

Hope it makes sense!

Message 6 of 11
rkmcswain
in reply to: navark

You might want to ask over in one of the customization forums, but as far as I know, it's possible with AutoCAD, but not AutoCAD LT.

 

R.K. McSwain     | CADpanacea | on twitter
Message 7 of 11
navark
in reply to: rkmcswain

So for anyone who's interested in this, the following seems to work ok with the exeption of bringing up the "save changes" window at the end:

 

Private Sub printpdf()

Dim dwgfileAs Range
Dim App As Object
Dim Doc As Object
Dim pdffile As String
Dim result As String

Set App = CreateObject("AutoCAD.Application")
Set dwgfile= Cells(1, 1)
pdffile = Cells(2, 1)

App.Visible = False

Set Doc = App.Documents.Open(dwgfile)
Doc.ActiveLayout.ConfigName = "DWG To PDF.pc3"

result = Doc.Plot.PlotToFile(pdffile)
App.Quit
End Sub

 

Et voilà!

 

Message 8 of 11
ampster402
in reply to: navark

and that is in an excel spreadsheet?

Message 9 of 11
navark
in reply to: ampster402

That's right.

Youjust need to add the reference to the Acad library. (in the VBA editor just go tool - reference and tick the corresponding library)

Message 10 of 11
navark
in reply to: navark

I would like to correct my previous post. As it was rightly pointed out this can work in the full version of autocad (which is what I was using to test the code) but not in LT unfortunately. All hope is not lost for LT automation though as explained here:

http://metamorphs.blogspot.fr/2011/10/programmingautomating-autocad-lt.html

 

Sorry for the confusion!

Message 11 of 11

Hello, I know that this topic is too old, but I tried your code and it worked! :D, butI wonder if it is possible to change the printing options, because the PDF file does not appear complete, and I would also like to know if it is possible to export a several lay outs, thanks a lot!!

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost