Hi Mike,
I personally use of the windows shell32 function "FindExecutable" which
returns the path to the program associated with a file type. The
function is not restricted to Excel files, it opens any file type with
any associated program. I also use it for PDF and other file types.
Here's the code:
The first function calls the windows API, the second is a custom
MapBasic function to interface with it.
Declare Function FindExecutable Lib "shell32.dll" Alias
"FindExecutableA"
(ByVal lpFile As String, ByVal lpDirectory As String, lpResult
As String *256) As Integer
Declare Function FindAndExecute (ByVal file_path As String, ByVal
file_name As String) As Logical
Function FindAndExecute (ByVal file_path As String, Byval file_name As
String) As Logical
Dim file_operation As Integer
Dim executable_path As String *256
file_operation = FindExecutable(file_name, file_path,
executable_path)
If file_operation > 32 Then
executable_path = LTrim$(RTrim$(executable_path))
Run Program executable_path + " " + file_path +
file_name
FindAndExecute = True
Else
Note "Unable to find a program associated with that file
type."
FindAndExecute = False
End If
End Function
Regards,
Jorge
___________________
Jorge Gil
Simulation Developer
SPACE SYNTAX
D +44 (0) 20 7940 1881
[EMAIL PROTECTED]
www.spacesyntax.com
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Sent: 25 October 2005 19:20
To: [email protected]
Subject: MI-L MapBasic opening Excel
Hello all,
I have a MapBasic app writing out a comma delimited file, then
launching Excel, where a macro opens and formats the data.
Here is the mb code:
sReportXLS = "myreport.xls"
sRunline = "C:\Program Files\Microsoft Office\Office11\Excel /e " +
chr$(34) + sReportXLS + chr$(34)
Run Program sRunline
My, question: is it possible to obtain the machine's Excel.exe path,
rather than having it hardwired? I want to be able to handle unexpected
Excel setups.
Thanks,
Mike
---------------------------------------------------------------------
List hosting provided by Directions Magazine | www.directionsmag.com |
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
Message number: 18495