launch apps ?

Discussion in 'AutoCAD' started by Matthew, Jan 19, 2004.

  1. Matthew

    Matthew Guest

    I would like to be able to launch Acrobat Reader to preview some associated
    information in a PDF format. I have been looking for the VBA equivalent to
    the AutoLisp "Startapp". Ii don't need to interact with the other program
    (get information from it). I would just like to open it to a specific file.

    Any help is greatly appreciated.
    Matthew
     
    Matthew, Jan 19, 2004
    #1
  2. Matthew

    Warren M Guest

    Hi Matthew.

    Look into the VBA function 'Shell'.
    This allows you to fire external apps.

    Or here's a declare statement I use accessing it through the win api:

    Public Declare Function ShellExecute Lib "shell32.dll" _
    Alias "ShellExecuteA" _
    (ByVal hWnd As Long, _
    ByVal lpOperation As String, _
    ByVal lpFile As String, _
    ByVal lpParameters As String, _
    ByVal lpDirectory As String, _
    ByVal nShowCmd As Long) As Long

    'Sample to fire up a pdf doc.
    Public Sub StartPDF()
    ShellExecute 0, "open", "C:\Temp\Temp.pdf", "", "", 1
    End Sub

    Hope this helps
    Warren Medernach
     
    Warren M, Jan 19, 2004
    #2
  3. Matthew

    Warren M Guest

    Warren M, Jan 19, 2004
    #3
  4. Matthew

    Matthew Guest

    Thanks. that works great.

    Matthew
     
    Matthew, Jan 19, 2004
    #4
  5. Matthew

    Fred Guest

    Hi

    I am new to the VBA thing; I tried the code that Warren supplied, it
    doesn't seem to work for me....

    Do I put the code into a new Module?


    I was also trying the StartApp command but didn't work either. This is what
    I had for a menu command....
    ^c^c(startapp "c://Program Files//Adobe//Acrobat//Reader//AcroRd32.exe"
    "c://temp//temp.pdf");;;

    It gave me ;
    Command: (startapp "c://Program Files//Adobe//Acrobat//Reader//AcroRd32.exe"
    "c:/temp/temp.pdf")
    nil

    Command:

    Thanks for help....

    Fred
     
    Fred, Jan 21, 2004
    #5
  6. Matthew

    developer Guest

    Fred, you can place the declare statement at the top (outside any procedures) of a module. You'll then be able to call that Win API shell function from within any module in your project. As for your AutoLISP code, the forward slashes should be changed to backslashes.
     
    developer, Jan 21, 2004
    #6
  7. Matthew

    Fred Guest

    Hi

    Thanks that worked....now I just got to figure out how to run a macro from
    the menu....Thanks .....
    As for the LISPstuff it didn't work I tried both;
    ^c^c(startapp "c:\\Program Files\\Adobe\\Acrobat//Reader\\AcroRd32.exe"
    "c:\\temp\\temp.pdf");;;
    and also I tried
    ^c^c(startapp "c:\Program Files\Adobe\Acrobat//Reader\AcroRd32.exe"
    "c:\temp\temp.pdf");;;

    and I got

    Command: (startapp "c:


    Thanks for the help!.... ;-)




    procedures) of a module. You'll then be able to call that Win API shell
    function from within any module in your project. As for your AutoLISP code,
    the forward slashes should be changed to backslashes.
     
    Fred, Jan 21, 2004
    #7
  8. Well, Developer was half right. In lisp you can use either a double
    backslash or a forward slash:

    ^c^c(startapp "c:\\Program Files\\Adobe\\Acrobat\\Reader\\AcroRd32.exe"
    "c:\\temp\\temp.pdf");;;

    or

    ^c^c(startapp "c:/Program Files/Adobe/Acrobat/Reader/AcroRd32.exe"
    "c:/temp/temp.pdf");;;

    You were *definitely* having issues between Acrobat and Reader - you
    left it as "Acrobat//Reader" in both of your examples:)

    ___________________________
    Mike Tuersley
    CADalyst's AutoCAD Clinic
    Rand IMAGINiT Technologies
     
    Mike Tuersley, Jan 21, 2004
    #8
  9. Matthew

    Fred Guest

    Hi Mike

    I tried both your suggestions with the double forward and the back slashes,
    and no luck;

    ^c^c(startapp "c:\\Program Files\\Adobe\\Acrobat\\Reader\\AcroRd32.exe"
    "c:\\temp\\temp.pdf");;;

    When I select the menu item i am getting ( ia m pressing enter after each
    command, just to show you what I am getting)

    Command: (startapp "c:
    ("_>
    ("_> Program Files
    ("_>
    ("_> Adobe
    ("_>
    ("_> Acrobat
    ("_>
    ("_> Reader
    ("_>
    ("_> AcroRd32.exe" "c:
    ("_>
    ("_> temp
    ("_>
    ("_> temp.pdf")
    nil


    Thanks for the help....
     
    Fred, Jan 21, 2004
    #9
  10. Hi Fred,

    It's probably the blank space(s) in the filename/path. According to help for
    "startapp" any arguments containing spaces must be enclosed in double
    quotes.

    HTH

    Gary
     
    Gary McMaster, Jan 21, 2004
    #10
  11. Matthew

    Fred Guest

    Hi Gary

    I tried but with no luck;
    ^c^c(startapp "/"Program Files/Adobe/Acrobat/Reader/AcroRd32.exe/""
    "c:/temp/temp.pdf");;;


    and my result was;

    Command: (startapp "/"Program Files/Adobe/Acrobat/Reader/AcroRd32.exe/""
    "c:/temp/temp.pdf")
    nil


    Thanks for the help


    Fred
     
    Fred, Jan 21, 2004
    #11
  12. Looks like you have that code in a tool button.

    Have you tried simply pasting the startapp statement on the command line
    without the escapes and other toolbar codes?
    Maybe even try starting acrobat without specifying a document.

    The statement you posted works for me (acad2000) (acrobat 5.0) when pasted
    to the command line (without the extras).

    Gary
     
    Gary McMaster, Jan 21, 2004
    #12
  13. Matthew

    Fred Guest

    hmm interesting...

    I am running all of this through the menus....no toolbars...
    I tried taking the stuff, like you mentioned, out so I had...
    (startapp "/"Program Files/Adobe/Acrobat 6.0/Reader/AcroRd32.exe/""
    "c:/temp/temp.pdf")

    But
    still no luck its givng me a 'nil' after i start the command
     
    Fred, Jan 21, 2004
    #13
  14. Matthew

    Ed Jobe Guest

    (startapp) always returns nil. You are using forward slashes as control
    characters:
    (startapp "/"Program Files/Adobe/Acrobat/Reader/AcroRd32.exe/""
    "c:/temp/temp.pdf")
    should be
    (startapp "\"Program Files/Adobe/Acrobat/Reader/AcroRd32.exe\""
    "c:/temp/temp.pdf")

    This should work, provided it is a valid path to adobe *and* the pdf.
     
    Ed Jobe, Jan 21, 2004
    #14
  15. Matthew

    Fred Guest

    Hi Ed;

    I have
    (startapp "\"Program Files/Adobe/Acrobat/Reader/AcroRd32.exe\""
    "c:/temp/temp.pdf")

    and I got at the line command
    Command: (startapp "

    path for the file is correct and the file exists on my hardrive....
     
    Fred, Jan 21, 2004
    #15
  16. Matthew

    Ed Jobe Guest

    It may be how you are pasting the text. Try entering it directly in the text
    window (F2). I just tested it on my machine.
     
    Ed Jobe, Jan 21, 2004
    #16
  17. Matthew

    Fred Guest

    Hi Ed;

    Thanks for the help....still no luck...not sure what is going on....I did a
    search for some other posts and a couple fellas had the same occurence with
    the nil....

    I am running WinXP, ACAD2004 Adobe 6 Reader....

    I think it must be in the path...cuz the VBA routine at the beggining of
    this post works fine for me....

    Thanks for the help

    Fred
     
    Fred, Jan 21, 2004
    #17
  18. Matthew

    Fred Guest

    Hi

    I should of tried this before....but never thought of it...I ran....
    (startapp "C:\\Program Files\\Adobe\\Acrobat 5.0\\Reader\\AcroRd32.exe"
    "c:\\temp\\temp.pdf")

    this works on AutoCAD 2000i and it WORKED...no problem...but ACAD 2004 and
    it didn't work there is a problem....

    still lookin....

    Thanks again...
     
    Fred, Jan 22, 2004
    #18
  19. That's the same statement that work for me (Acrobat 5.0) with Acad2000

    Could it be a bug in Acad2004?

    Gary
     
    Gary McMaster, Jan 22, 2004
    #19
  20. I should of tried this before....but never thought of it...I ran....
    Yeah, that's what I posted for you yesterday. It should work fine in
    2004....try this:

    copy AcroRd32.exe to c:\temp
    then try opening the pdf file

    If this works, it's the space in your path. If it doesn't, try doing the
    same thing with Notepad and a text file to see if it is specific to
    AcroReader.
    ___________________________
    Mike Tuersley
    CADalyst's AutoCAD Clinic
    Rand IMAGINiT Technologies
     
    Mike Tuersley, Jan 22, 2004
    #20
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.