Jump to content

Recommended Posts

Posted

Hello All,

 

Ok, I am trying to open a PDF in a specific folder and add an argument to navigate to a bookmark or page. I know this can be done using outlook for example:

 

 (startapp "C:\\Program Files (x86)\\Microsoft Office\\Office12\\OUTLOOK.EXE"
 [email="email@server.com"]mailto:email@server.com[/email])) 

 

Any thoughts?

 

Thanks,

Matt

Posted
Hello All,

 

Ok, I am trying to open a PDF in a specific folder and add an argument to navigate to a bookmark or page. I know this can be done using outlook for example:

 

 (startapp "C:\\Program Files (x86)\\Microsoft Office\\Office12\\OUTLOOK.EXE"
[email="email@server.com"]mailto:email@server.com[/email])) 

 

Any thoughts?

 

Thanks,

Matt

 

You must add the location of outlook.exe to the AutoCAD Search Support Path in your options.

Document1.JPG

Posted

I've delved into interfacing with Adobe using OLE Automation in the past to no avail, but I believe some of the application string do work.

 

However, to open PDF files, I've always found this to be reliable:

 

[i][color=#990099];;----------------------=={ Open File }==---------------------;;[/color][/i]
[i][color=#990099];;                                                            ;;[/color][/i]
[i][color=#990099];;  Uses the 'Open' method of the Shell Object to open the    ;;[/color][/i]
[i][color=#990099];;  specified file.                                           ;;[/color][/i]
[i][color=#990099];;------------------------------------------------------------;;[/color][/i]
[i][color=#990099];;  Author: Lee McDonnell, 2010 - www.lee-mac.com             ;;[/color][/i]
[i][color=#990099];;                                                            ;;[/color][/i]
[i][color=#990099];;  Copyright © 2010 by Lee McDonnell, All Rights Reserved.   ;;[/color][/i]
[i][color=#990099];;  Contact: Lee @ lee-mac.com                                ;;[/color][/i]
[i][color=#990099];;  Forums: Lee Mac @ TheSwamp.org, CADTutor.net, AUGI.com    ;;[/color][/i]
[i][color=#990099];;------------------------------------------------------------;;[/color][/i]
[i][color=#990099];;  Arguments:                                                ;;[/color][/i]
[i][color=#990099];;  filename - filename of file to open                       ;;[/color][/i]
[i][color=#990099];;------------------------------------------------------------;;[/color][/i]
[i][color=#990099];;  Returns:  T if file opened successfully, else nil         ;;[/color][/i]
[i][color=#990099];;------------------------------------------------------------;;[/color][/i]

[b][color=RED]([/color][/b][b][color=BLUE]defun[/color][/b] LM:OpenFile [b][color=RED]([/color][/b] filename [b][color=BLUE]/[/color][/b] Shell result [b][color=RED])[/color][/b]
 [b][color=RED]([/color][/b][b][color=BLUE]vl-load-com[/color][/b][b][color=RED])[/color][/b]
 [i][color=#990099];; © Lee Mac 2010[/color][/i]
 
 [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] Shell [b][color=RED]([/color][/b][b][color=BLUE]vla-getInterfaceObject[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vlax-get-acad-object[/color][/b][b][color=RED])[/color][/b] [b][color=#a52a2a]"Shell.Application"[/color][/b][b][color=RED]))[/color][/b]

 [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] result
   [b][color=RED]([/color][/b][b][color=BLUE]and[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] filename [b][color=RED]([/color][/b][b][color=BLUE]findfile[/color][/b] filename[b][color=RED]))[/color][/b]
     [b][color=RED]([/color][/b][b][color=BLUE]not[/color][/b]
       [b][color=RED]([/color][/b][b][color=BLUE]vl-catch-all-error-p[/color][/b]
         [b][color=RED]([/color][/b][b][color=BLUE]vl-catch-all-apply[/color][/b]
           [b][color=RED]([/color][/b][b][color=BLUE]function[/color][/b] [b][color=BLUE]vlax-invoke[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]list[/color][/b] Shell [b][color=DARKRED]'[/color][/b][b][color=BLUE]Open[/color][/b] filename[b][color=RED])[/color][/b]
         [b][color=RED])[/color][/b]
       [b][color=RED])[/color][/b]
     [b][color=RED])[/color][/b]
   [b][color=RED])[/color][/b]
 [b][color=RED])[/color][/b]
 
 [b][color=RED]([/color][/b][b][color=BLUE]vlax-release-object[/color][/b] Shell[b][color=RED])[/color][/b]
 result
[b][color=RED])[/color][/b]

Posted

Well,

 

I use this quite often to open a file, my problem is i need to then navigate to a specific page:

 

(startapp "Explorer" "M:\\Standards\\Admin-Reference Material\\Documentation\\Plumbing - User Manual.pdf")

 

As an example.

 

Matt

Posted

Ok, I think I have something working...

 

You can find the location of the shell command string which can be used to open the pdf document in the registry, under:

 

HKEY_CLASSES_ROOT\\.pdf

This will point you to another location under HKCR, something like 'AcroExch.Document'. Navigate to the Shell Open Command Key under this entry:

 

HKEY_CLASSES_ROOT\\AcroExch.Document\\Shell\\Open\\Command

There you will find the command string to open the pdf document, something like:

 

"C:\Program Files\Adobe\Reader 8.0\Reader\AcroRd32.exe" "%1"

Where "%1" is the filename of the PDF.

 

Now, after a bit of research, there are quite a few PDF Open parameters you can use with this string, so to open to a specific page (page 3 in this case), you can use:

 

(startapp "\"C:\Program Files\Adobe\Reader 8.0\Reader\AcroRd32.exe\" /A \"page=3\" \"C:\\MyPDF.pdf\"")

Lee

Posted
I've delved into interfacing with Adobe using OLE Automation in the past to no avail, but I believe some of the application string do work.

 

However, to open PDF files, I've always found this to be reliable:

Is there any advantage to using

(vla-getInterfaceObject (vlax-get-acad-object) "Shell.Application")

over

(vlax-create-object "Shell.Application")

?

 

I've used vlax-create-object to successfully open files, on many occasions.

Posted

Now, Lee that is exactly what i am looking for, now thank you for bringing up the registry items for opening the PDF not everyone has the same program. Just brilliant, brilliant! Alright this is what i have:

 

(setq opdoc (vl-registry-read "HKEY_CLASSES_ROOT\\.pdf"))
(setq opstr (vl-registry-read (strcat "HKEY_CLASsES_ROOT\\" OPDOC "\\shell\\open\\command"))) 

 

Now I would like to get the path of the executable only, how would i go about that?

 

Matt

Posted
Is there any advantage to using

(vla-getInterfaceObject (vlax-get-acad-object) "Shell.Application")

over

(vlax-create-object "Shell.Application")

?

 

I've used vlax-create-object to successfully open files, on many occasions.

 

I'm not sure there is too much difference, but I've noticed a difference with ObjectDBX Objects on some versions. Well, that said, I'm sure someone with more knowledge will be able to point out the difference :)

Posted
Now I would like to get the path of the executable only, how would i go about that?

 

Maybe something similar to this?

 

(defun GetAdobePath ( / AcroDoc AcroPath )
 (vl-load-com)

 (if
   (and
     (setq AcroDoc (vl-registry-read "HKEY_CLASSES_ROOT\\.pdf"))
     (setq AcroPath
       (vl-registry-read
         (strcat "HKEY_CLASSES_ROOT\\" AcroDoc "\\Shell\\Open\\Command")
       )
     )
   )
   (car (LM:str->lst AcroPath "\""))
 )
)



;;-------------------=={ String to List }==-------------------;;
;;                                                            ;;
;;  Separates a string into a list of strings using a         ;;
;;  specified delimiter string                                ;;
;;------------------------------------------------------------;;
;;  Author: Lee McDonnell, 2010                               ;;
;;                                                            ;;
;;  Copyright © 2010 by Lee McDonnell, All Rights Reserved.   ;;
;;  Contact: Lee Mac @ TheSwamp.org, CADTutor.net             ;;
;;------------------------------------------------------------;;
;;  Arguments:                                                ;;
;;  str - string to process                                   ;;
;;  del - delimiter by which to separate the string           ;;
;;------------------------------------------------------------;;
;;  Returns:  A list of strings                               ;;
;;------------------------------------------------------------;;

(defun LM:str->lst ( str del / pos )
 ;; © Lee Mac 2010
 (if (setq pos (vl-string-search del str))
   (vl-remove "" (cons (substr str 1 pos) (LM:str->lst (substr str (+ pos 1 (strlen del))) del)))
   (list str)
 )
)

Posted
I'm not sure there is too much difference, but I've noticed a difference with ObjectDBX Objects on some versions. Well, that said, I'm sure someone with more knowledge will be able to point out the difference :)
Interesting. OK.
Posted
Interesting. OK.

 

I think the rule would be: If you want it to run within AutoCAD, then vla-getinterfaceobject (such as for BrowseForFolder/ObjectDBX), else vlax-get-or-create-object/vlax-create-object (such as for Excel apps etc) - but that's just a guess tbh.

Posted
I think the rule would be: If you want it to run within AutoCAD, then vla-getinterfaceobject (such as for BrowseForFolder/ObjectDBX), else vlax-get-or-create-object/vlax-create-object (such as for Excel apps etc) - but that's just a guess tbh.

Hard to say. I've seen the same function executed with both.

  • 12 years later...
Posted (edited)

As always inspired from Master Lee the general function for every app

;; ext - application files extension (e.g. for excel use xlsx) ;;



(defun GetAppPath ( ext / AppDoc AppPath )
 (vl-load-com)

 (if
   (and
     (setq AppDoc (vl-registry-read (strcat "HKEY_CLASSES_ROOT\\." ext)))
     (setq AppPath
       (vl-registry-read
         (strcat "HKEY_CLASSES_ROOT\\" AppDoc "\\Shell\\Open\\Command")
       )
     )
   )
   (car (LM:str->lst AppPath "\""))
 )
)

 

Edited by SLW210
Added Code Tags! <>
Posted

Also, please use Code Tags (<> in the reply toolbar) in the future.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...