Jorge,

I like your solution but for it to work properly, it needs a small
correction in the run program command that should read

                Run Program executable_path + " " + chr$(34)+ file_path +
file_name +chr$(34)

I do not know if a path containing spaces caused the trouble but with the
quotation marks it works in all circumstances.


Jacques Paris
e-mail  [EMAIL PROTECTED]
MapBasic-MapInfo support  http://www.paris-pc-gis.com



-----Original Message-----
From: Jorge Gil [mailto:[EMAIL PROTECTED]
Sent: October 27, 2005 10:42
To: [EMAIL PROTECTED]; [email protected]
Subject: RE: MI-L MapBasic opening Excel

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




---------------------------------------------------------------------
List hosting provided by Directions Magazine | www.directionsmag.com |
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
Message number: 18502

Reply via email to