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

 


All content is copyright © CAD PANACEA 2005-2011 unless otherwise noted.
All content of CAD PANACEA is solely my own personal thoughts and opinions and do not those of any other entity or person.
All comments posted to this blog are the sole responsibility of the person making the comment.

 

Google, as a third party vendor, uses cookies to serve ads on this site. Google's use of their cookies enables it to serve ads to users based on their visit to your sites and other sites on the Internet. You may opt out of the use of these cookies by visiting the Google ad and content network privacy policy.

free hit counters

Powered by Drupal, an open source content management system