You can also use DDE. Here is some Access VBA code (you don't need it all :)

Jakob
http://www.lanstorp.com

> *****
>
> Public Function ButtonGetQuery()
>
> Dim objDatasheet As Object
> Dim rs As DAO.Recordset
> Dim i As Integer
>
>     Const conNoActiveDatasheet = 2484
>     On Error GoTo GetSelection_Err
>
>     Set objDatasheet = Screen.ActiveDatasheet
>     Set rs = objDatasheet.Recordset
>     'MsgBox objDatasheet.Name
>
>     i = 0
>     rs.MoveFirst
>     Do Until rs.EOF
>         i = i + 1
>         ReDim Preserve arrGeocodeQuery(i)
>         arrGeocodeQuery(i) = rs!Geokode
>         'MsgBox arrGeocodeQuery(i)
>         rs.MoveNext
>     Loop
>
>     Set objDatasheet = Nothing
>     Set rs = Nothing
>
>     '-------------------------------------------
>     'DDE RUTINE FOR DATASHEET
>     '-------------------------------------------
>
>     Dim nChannel_1 As Long
>     Dim nChannel_2 As Long
>     Dim szPathMBX As String
>     Dim szEye As String
>
>     szEye = Chr(34)
>
>     On Error Resume Next
>
>     '--------------------
>     '*n c h a n n e l _ 1
>     '--------------------
>
>     '*establish link to mapinfo
>     nChannel_1 = DDEInitiate("MapInfo", "System")
>
>     '*if mapinfo not running
>     If Err.Number <> 0 Then
>         Err = 0
>
>         '*run the mbx program
>         Shell "C:\Programmer\MapInfo 6.0 DK\Professional\mapinfow.exe " &
"
> " & _
>             "D:\mapbasic\FynsAmt\Program\MB_Natur.MBX", 1
>
>         '*if another error, exit
>         If Err Then Exit Function
>
>         '*establish mapinfo link
>         nChannel_1 = DDEInitiate("MapInfo", "System")
>     End If
>
>     '*MB strings to mapinfo
>     'DDEExecute nChannel_1, "set window message position (1,1)"
>     'DDEExecute nChannel_1, "Print Chr$(12)"
>
>     '--------------------
>     '*n c h a n n e l _ 2
>     '--------------------
>
>     '*try to establish link to mbx
>     nChannel_2 = DDEInitiate("MapInfo", "MB_Natur.mbx")
>
>     '*if no mbx in mapinfo then run it
>     If nChannel_2 = 0 Then
>
>         szPathMBX = "D:\mapbasic\FynsAmt\Program\MB_Natur.mbx"
>
>         DDEExecute nChannel_1, "Run Application " & szEye & szPathMBX &
> szEye
>
>         '*establish link to mbx
>         nChannel_2 = DDEInitiate("MapInfo", "MB_Natur.mbx")
>
>     End If
>
>     '*transfer geokode(s) to remote mbx handler
>     'send the size of array to mb
>     DDEExecute nChannel_2, "%" & UBound(arrGeocodeQuery)
>     'MsgBox "dde loop..."
>     For i = 1 To UBound(arrGeocodeQuery)
>         DDEExecute nChannel_2, "�" + arrGeocodeQuery(i)
>        'MsgBox "arr: " & i & " : " & arrGeocodeQuery(i)
>     Next
>     'zero the loop variable in MB
>     DDEExecute nChannel_2, "#"
>     'Close Form_Lokalitet
>
>     DDEExecute nChannel_2, "Call MIfront"
>     'DDEExecute nChannel_1, "Set Window MapInfo Front"
>
>     DDETerminate nChannel_1
>     DDETerminate nChannel_2
>
>     Exit Function
>
> GetSelection_Bye:
>     MsgBox "Ingen aktiv dataark at overf�re til MapInfo..."
>     Exit Function
> GetSelection_Err:
>     If Err = conNoActiveDatasheet Then
>         Resume GetSelection_Bye
>     End If
>
>
> '    Dim item As Object
> '    Dim arrGeocodeQuery(0) As String
> '    Dim db As Database
> '    Dim rs As DAO.Recordset
> '    Dim szTab As String
> '
> '    Set db = CurrentDb
> '    Set rs = db.OpenRecordset("pad-reg") '(item.Name)
> '    'Set rs = db.OpenRecordset("fugleart") 'szTab)
> '
> '    For Each item In CurrentDb.QueryDefs
> '        Select Case item.Name
> '            Case "fugleart"
> '                MsgBox item.Name
> '                szTab = item.Name
> '
> '                Do Until rs.EOF
> '                    MsgBox "feltv�rdi: " & rs!Geokode
> '                    rs.MoveNext
> '                Loop
> '            'Case "planteart"
> '            '    MsgBox item.Name
> '            'Case "paddeart"
> '            '    MsgBox item.Name
> '        End Select
> '    Next
> '
> '    db.Close
> '    Set db = Nothing
> '    Set rs = Nothing
>
>     '---------------------------
>     '---------------------------
> End Function
>
> ----- Original Message ----- 
> From: "Sean Connolly" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Thursday, August 21, 2003 3:48 PM
> Subject: MI-L Check if Mapinfo Professional Open
>
>
> Hi,
>
>
> I'm trying to write some code in access that checks if Mapinfo is already
> open before launching a new instance of it.  If used the standard windows
> FindWindow API.  Searching by either MapInfo's classname or window caption
> returns zero results, thing is if I do this with any other application it
> works fine.  Anyone got any ideas/suggestions ?
>
> Kind Regards
>
> S�an
>
> ---------------------------------------------------------------------
> List hosting provided by Directions Magazine | www.directionsmag.com |
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> Message number: 8107
>
>



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

Reply via email to