Apologies if my last post was a bit extreme, this would probably
suffice.
Declare Sub DDETest
Sub DDETest
Dim i_chan_num as Integer
i_chan_num = DDEInitiate("Excel", "Sheet1")
DDEPoke i_chan_num, "R10C2", "GIS is Sexy" 'R10 = row 10 C2 = column 2
end sub
-----Original Message-----
From: Ellingham Morgan
Sent: Thursday, 6 October 2005 11:39 AM
To: [email protected]
Subject: RE: MI-L Hotlink to specific Cell or sheet in Excel
You would have to use DDE (Dynamic Data Exchange) within MapBasic.
It might look similar to this (from MapBasic Manual);
Dim chan_num, tab_marker As Integer
Dim topiclist, topicname, cell As String
chan_num = DDEInitiate("EXCEL", "System")
If chan_num = 0 Then
Note "Excel is not responding."
End Program
End If
topiclist = DDERequest$(chan_num, "topics")
' Topics in the list are separated by tabs.
' If Excel 4 is running, topiclist might look like:
' ": Sheet1 System"
' (if spreadsheet is still "unnamed"),or like:
' ": C:Orders.XLS Sheet1 System"
'
' If Excel 5 is running, topiclist might look like:
' "[Book1]Sheet1 [Book2]Sheet2 ..."
'
' Next,extract just the first topic (for example,"Sheet1")
' by extracting the text between the 1st & 2nd tabs;
' or, in the case of Excel 5, by extracting the text
' that appears before the first tab.
If Left$(topiclist, 1) = ":" Then
' ...then it's Excel 4.
tab_marker = InStr(3, topiclist, Chr$(9) )
If tab_marker = 0 Then
Note "No Excel documents in use! Stopping."
End Program
End If
topicname = Mid$(topiclist, 3, tab_marker - 3)
Else
' ... assume it's Excel 5.
tab_marker = Instr(1, topiclist, Chr$(9) )
topicname = Left$( topiclist, tab_marker - 1)
End If
' open a channel to the specific document
' (for example, "Sheet1")
DDETerminate chan_num
chan_num = DDEInitiate("Excel", topicname)
If chan_num = 0 Then
Note "Problem communicating with " + topicname
End Program
End If
' Let's examine the 1st cell in Excel.
' If cell is blank, put a message in the cell.
' If cell isn't blank, don't alter it -
' just display cell contents in a MapBasic NOTE.
' Note that a "Blank cell" gets returned as a
' carriage-return line-feed sequence:
' Chr$(13) + Chr$(10).
cell = DDERequest$( chan_num, "R1C1" )
If cell <> Chr$(13) + Chr$(10) Then
Note
"Message not sent; cell already contains:" + cell
Else
DDEPoke chan_num, "R1C1", "Hello from MapInfo!"
Note "Message sent to Excel,"+topicname+ ",R1C1."
End If
DDETerminateAll
Regards...
Morgan Ellingham
Citywide Service Solutions
GIS Technical Officer
Level 1, 150 Jolimont Rd, East Melbourne
Ph: (03) 9261 5065
Mob: 0419 145 666
Email: [EMAIL PROTECTED]
-----Original Message-----
From: Graham Bish [mailto:[EMAIL PROTECTED]
Sent: Thursday, 6 October 2005 10:39 AM
To: [email protected]
Subject: MI-L Hotlink to specific Cell or sheet in Excel
Hi All
I need to be able to hotlink to a specific sheet/cell in a excel
workbook.
I have had great success with hotlinks to files but this would the next
logical step.
I have tried using syntax like you would in standard hyperlinks but had
no luck
Does anyone have any ideas?
Kind regards
Graham Bish
Senior Consultant
Neil Clark & Associates
Ph. 03 5441 1244
Fx. 03 5441 1366
---------------------------------------------------------------------
List hosting provided by Directions Magazine | www.directionsmag.com |
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
Message number: 18146
---------------------------------------------------------------------
List hosting provided by Directions Magazine | www.directionsmag.com |
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
Message number: 18147