Its that time of the year for giving out gifts and such... so today I have decided to drop a smaple of code that deomstrates how to print a MS Word document using AutoLISP. What a great way to print your holiday newsletter while the boss things you are working in AutoCAD. OK maybe not thebest of uses for the code sample. It is possible to automate the printing process of not only your AutoCAD drawings, but also the spces that might need to go out with them at the same time. The code can be modified to specifiy a printer if need be, but it is designed to go to the default printer though.
:: Begin Code
;; Written by: Lee Ambrosius, HyperPics LLC
;; Usage: (PrintMSWordDoc "C:\\test.doc")
;; Open a document in MS Word and Print it out
(defun PrintMSWordDoc ( strWordDoc / wordObj wordDocsObj wordDocObj)
(vl-load-com)
;; Variable to define constant used in the Close and Quit methods
(setq wdDoNotSaveChanges 0)
;; Create a new MS Word object
(setq wordObj (vlax-invoke-method (vlax-get-acad-object) 'GetInterfaceObject "Word.Application"))
;; Get a reference to the Docuemnts collection in Word
(setq wordDocsObj (vlax-get-property wordObj 'Documents))
;; Open the drawing
(setq wordDocObj (vlax-invoke-method wordDocsObj 'Open strWordDoc))
;; Print it out
(vlax-invoke-method wordDocObj 'PrintOut)
;; Close the document and don't save any changes
(vlax-invoke-method wordDocObj 'Close wdDoNotSaveChanges)
;; Close the instance of the MS Word application
(vlax-invoke-method wordObj 'Quit wdDoNotSaveChanges)
(princ)
)
;; End Code
Sincerely,
Lee
Hi! ,
Could you let me know how to retireve records from autocad once the user inputs the record number and then print that same record. Need the code for this please help.
P:S: I'm new to autocad so please be more detailed.
Posted by: Jude | Saturday, February 04, 2006 at 12:20 AM
Hi!
Could I connect MS Excel with AutoCAD. It is so that the datas in Excel should be the length of line in autocad.
Posted by: Shahid Akhtar | Friday, March 17, 2006 at 03:48 AM
Dear sir,
I am working in AutoCAD with auto lisp project. I am having the coding in auto lisp for the drawing. But I do not know, how to get the output in excel through VB. Is any other way there to get the output?
Plz help me.
Posted by: Viji | Tuesday, May 09, 2006 at 04:08 AM