CAD PANACEA HAS MOVED TO http://cadpanacea.com
22 November 2005
Launch PDF from AutoCAD          
If you need the ability to launch a PDF file from a menu macro, lisp file, or VBA routine, check out the code shown below. This will launch the PDF using the default registered application, just as if you had entered the file name in the Windows Start-Run dialog

This avoids any browser related issues which can arise if you use the AutoCAD "BROWSER" command.

It makes no assumptions regarding the application (or it's version) used to open a PDF document, or the presence of a properly configured PGP file.


;;;==============================
;;; LISP EXAMPLE
;;;==============================
(defun C:LaunchPDF (/ shell)
(vl-load-com)
(setq filename "\\\\server\\share\\mydoc.pdf")
(setq shell
(vla-getinterfaceobject
(vlax-get-acad-object)
"Shell.Application"
)
)
(vlax-invoke-method shell 'Open filename)
(vlax-release-object shell)
)



'================================
' VBA EXAMPLE
'================================
Private Sub LaunchPDF()
Dim fn As String, objShell As Object
fn = "\\server\share\mydoc.pdf"
Set objShell = CreateObject("Shell.Application")
objShell.Open (fn)
Set objShell = Nothing
End Sub

Labels: , ,


PermaLink       Posted 11/22/2005 02:00:00 PM     
3 COMMENTS!


Comment from: Blogger Avatart
Date: April 3, 2008 at 7:53:00 AM CDT  

That Lisp example was exactly what I was looking for, thanks.

Avatart (AUGI)


Comment from: Anonymous Anonymous
Date: August 12, 2008 at 6:27:00 PM CDT  

does this routine work with autocad 2008? can anyone confirm it please?


Comment from: Blogger R.K. McSwain
Date: August 13, 2008 at 6:30:00 AM CDT  

Yes, it should work in all versions from 2000 to 2009.

Post a comment