Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Can I run an external program?
I'd like to be able have a routine that launches a PDF file. The
closest thing I can find it the ActivateMicrosoftApp Method which, of course doesn't work with the Adobe product files. Any ideas? |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Can I run an external program?
Hi
have a look at the Shell method -- Regards Frank Kabel Frankfurt, Germany schrieb im Newsbeitrag ups.com... I'd like to be able have a routine that launches a PDF file. The closest thing I can find it the ActivateMicrosoftApp Method which, of course doesn't work with the Adobe product files. Any ideas? |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Can I run an external program?
You will have to shell the AcroRd32.exe file, so you will need to get the
full path for that file. -- HTH RP (remove nothere from the email address if mailing direct) "Frank Kabel" wrote in message ... Hi have a look at the Shell method -- Regards Frank Kabel Frankfurt, Germany schrieb im Newsbeitrag ups.com... I'd like to be able have a routine that launches a PDF file. The closest thing I can find it the ActivateMicrosoftApp Method which, of course doesn't work with the Adobe product files. Any ideas? |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Can I run an external program?
I tried the following:
Sub RunHelpFile() ' Specifying 1 as the second argument opens the application in ' normal size and gives it the focus. Dim RetVal RetVal = Shell("C:\Program Files\Coax Designer II\Coax Designer II.pdf", 1) ' Run program. End Sub I get an "Invalid procedure call or argument (Error 5)" error message however. |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Can I run an external program?
I tried the following:
Sub RunHelpFile() ' Specifying 1 as the second argument opens the application in ' normal size and gives it the focus. Dim RetVal RetVal = Shell("C:\Program Files\Coax Designer II\Coax Designer II.pdf", 1) ' Run program. End Sub I get an "Invalid procedure call or argument (Error 5)" error message however. |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
Can I run an external program?
Simon
Consider using the FollowHyperlink method. It will open the file according to your Windows associations. See http://www.dicks-blog.com/archives/2...nt-file-types/ -- Dick Kusleika Excel MVP Daily Dose of Excel www.dicks-blog.com wrote: I'd like to be able have a routine that launches a PDF file. The closest thing I can find it the ActivateMicrosoftApp Method which, of course doesn't work with the Adobe product files. Any ideas? |
#7
Posted to microsoft.public.excel.programming
|
|||
|
|||
Can I run an external program?
Thanks, Dick. I tried the following:
Sub RunHelpFile() Dim sPath As String sPath = "C:\Program Files\Coax Designer II\" ActiveWorkbook.FollowHyperlink sPath & "CoaxDesignerII.pdf" End Sub but I get a Variable not defined error with the "CoaxDesignerII" (of the filename) highlighted. |
#8
Posted to microsoft.public.excel.programming
|
|||
|
|||
Can I run an external program?
Hi Dick,
Dick Kusleika wrote: I'd like to be able have a routine that launches a PDF file. The closest thing I can find it the ActivateMicrosoftApp Method which, of course doesn't work with the Adobe product files. Consider using the FollowHyperlink method. It will open the file according to your Windows associations. See http://www.dicks-blog.com/archives/2...nt-file-types/ Personally, I don't like using the FollowHyperlink method for anything but URLs. On my machine (Win XP SP2), I get a warning telling me that links may harm my computer. Here's a way to do it with the API, which is cleaner and gives you more options on how you want to display the document and what to do if it's not found: Public Const SW_SHOWMAXIMIZED = 3 Public Const ERROR_FILE_NOT_FOUND = 2& 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 Public Function gbOpenDocument(rsFullPath As String, _ rsErrMsg As String) As Boolean Dim lResponse As Long lResponse = ShellExecute(Application.hwnd, _ "open" & vbNullChar, rsFullPath & vbNullChar, _ vbNull, vbNull, SW_SHOWMAXIMIZED) If lResponse = ERROR_FILE_NOT_FOUND Then rsErrMsg _ = "File not found." gbOpenDocument = (lResponse 32) End Function Sub test() Dim sErr As String Debug.Print gbOpenDocument("c:\test234.pdf", sErr) If Len(sErr) Then Debug.Print sErr End Sub -- Regards, Jake Marx MS MVP - Excel www.longhead.com [please keep replies in the newsgroup - email address unmonitored] |
#9
Posted to microsoft.public.excel.programming
|
|||
|
|||
Can I run an external program?
You need to specify the program as I said
RetVal = Shell("C:\Program Files\Adobe\Acrobat 5.0\Reader\AcroRd32.exe Coax Designer II.pdf", 1) -- HTH RP (remove nothere from the email address if mailing direct) wrote in message ups.com... I tried the following: Sub RunHelpFile() ' Specifying 1 as the second argument opens the application in ' normal size and gives it the focus. Dim RetVal RetVal = Shell("C:\Program Files\Coax Designer II\Coax Designer II.pdf", 1) ' Run program. End Sub I get an "Invalid procedure call or argument (Error 5)" error message however. |
#10
Posted to microsoft.public.excel.programming
|
|||
|
|||
Can I run an external program?
I don't know what would cause that error. It worked okay for me. Make sure
you have everything spelled right and you have double quotes around the strings. -- Dick Kusleika Excel MVP Daily Dose of Excel www.dicks-blog.com wrote: Thanks, Dick. I tried the following: Sub RunHelpFile() Dim sPath As String sPath = "C:\Program Files\Coax Designer II\" ActiveWorkbook.FollowHyperlink sPath & "CoaxDesignerII.pdf" End Sub but I get a Variable not defined error with the "CoaxDesignerII" (of the filename) highlighted. |
#11
Posted to microsoft.public.excel.programming
|
|||
|
|||
Can I run an external program?
Jake
I don't get that message, but I'm not sure which SP I'm on. I like the API method, though. Sounds like a blog post in the making. -- Dick Kusleika Excel MVP Daily Dose of Excel www.dicks-blog.com Jake Marx wrote: Hi Dick, Dick Kusleika wrote: I'd like to be able have a routine that launches a PDF file. The closest thing I can find it the ActivateMicrosoftApp Method which, of course doesn't work with the Adobe product files. Consider using the FollowHyperlink method. It will open the file according to your Windows associations. See http://www.dicks-blog.com/archives/2...nt-file-types/ Personally, I don't like using the FollowHyperlink method for anything but URLs. On my machine (Win XP SP2), I get a warning telling me that links may harm my computer. Here's a way to do it with the API, which is cleaner and gives you more options on how you want to display the document and what to do if it's not found: Public Const SW_SHOWMAXIMIZED = 3 Public Const ERROR_FILE_NOT_FOUND = 2& 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 Public Function gbOpenDocument(rsFullPath As String, _ rsErrMsg As String) As Boolean Dim lResponse As Long lResponse = ShellExecute(Application.hwnd, _ "open" & vbNullChar, rsFullPath & vbNullChar, _ vbNull, vbNull, SW_SHOWMAXIMIZED) If lResponse = ERROR_FILE_NOT_FOUND Then rsErrMsg _ = "File not found." gbOpenDocument = (lResponse 32) End Function Sub test() Dim sErr As String Debug.Print gbOpenDocument("c:\test234.pdf", sErr) If Len(sErr) Then Debug.Print sErr End Sub |
#12
Posted to microsoft.public.excel.programming
|
|||
|
|||
Can I run an external program?
Instead of writing the code like this:
Sub RunHelpFile() Dim sPath As String sPath = "C:\Program Files\Coax Designer II\" ActiveWorkbook.FollowHyperlink sPath & "CoaxDesignerII.pdf" End Sub It should have been written like this: Sub RunHelpFile() Dim sPath As String sPath = "C:\Program Files\Coax Designer II\CoaxDesignerII.pdf" ActiveWorkbook.FollowHyperlink sPath End Sub Swisse |
#13
Posted to microsoft.public.excel.programming
|
|||
|
|||
Can I run an external program?
Why should it have been written like that?
Bob "swisse" wrote in message ... Instead of writing the code like this: Sub RunHelpFile() Dim sPath As String sPath = "C:\Program Files\Coax Designer II\" ActiveWorkbook.FollowHyperlink sPath & "CoaxDesignerII.pdf" End Sub It should have been written like this: Sub RunHelpFile() Dim sPath As String sPath = "C:\Program Files\Coax Designer II\CoaxDesignerII.pdf" ActiveWorkbook.FollowHyperlink sPath End Sub Swisse |
#14
Posted to microsoft.public.excel.programming
|
|||
|
|||
Can I run an external program?
Because the second one worked for me. I tested it before I posted here, and I
tested it again. Swisse |
#15
Posted to microsoft.public.excel.programming
|
|||
|
|||
Can I run an external program?
My point is that the first works as well, so there is no '... should be ...'
-- HTH RP (remove nothere from the email address if mailing direct) "swisse" wrote in message ... Because the second one worked for me. I tested it before I posted here, and I tested it again. Swisse |
#16
Posted to microsoft.public.excel.programming
|
|||
|
|||
Can I run an external program?
Actually, this version works best for me as I don't have to call the
host app (Acrobat Reader). The reason I'd rather not call this is that I can't be sure of the version someone is running, nor the actual path to it. This way, the file runs regardless. Thanks, |
#17
Posted to microsoft.public.excel.programming
|
|||
|
|||
Can I run an external program?
The first one did not work for me - the reason for the should be. Try the
first one and report back. Swisse |
#18
Posted to microsoft.public.excel.programming
|
|||
|
|||
Can I run an external program?
This version works best for me as it runs the file itself, so I don't
have to worry about the user having a different version of Acrobat Reader. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
how to pass a cell as parameter for an external program? | Excel Discussion (Misc queries) | |||
Copying data to an external Program | New Users to Excel | |||
How do I run an external program? | Excel Programming | |||
Open external program | Excel Programming | |||
starting an external program with a command line | Excel Programming |