Microsoft KB Archive/174498: Difference between revisions
From BetaArchive Wiki
(importing KB archive) |
m (Text replacement - "&" to "&") |
||
(One intermediate revision by the same user not shown) | |||
Line 51: | Line 51: | ||
== SUMMARY == | == SUMMARY == | ||
The Microsoft Access 97 Help Topic Example | The Microsoft Access 97 Help Topic Example "Dynamic Data Exchange (DDE) Example," which can be displayed by clicking Example on the following topics,<br /> | ||
<pre class="fixed_text"> - DDEEXecute Statement | <pre class="fixed_text"> - DDEEXecute Statement | ||
Line 69: | Line 69: | ||
On Error Resume Next ' Set up error handling. | On Error Resume Next ' Set up error handling. | ||
intChan1 = DDEInitiate( | intChan1 = DDEInitiate("Excel", "System") ' Establish link. | ||
If Err Then ' If error occurs, Excel | If Err Then ' If error occurs, Excel | ||
Err = 0 ' may not be running. | Err = 0 ' may not be running. | ||
' Reset error | ' Reset error | ||
Shell | Shell "C:\Excel\Excel.exe", 1 ' and start spreadsheet. | ||
If Err Then Exit Sub ' If another error, exit. | If Err Then Exit Sub ' If another error, exit. | ||
' Establish Spreadsheet link. | ' Establish Spreadsheet link. | ||
intChan1 = DDEInitiate( | intChan1 = DDEInitiate("Excel", "System") | ||
End If | End If | ||
' Create new worksheet. | ' Create new worksheet. | ||
DDEExecute intChan1, | DDEExecute intChan1, "[New(1)]" | ||
' Get topic list, worksheet name. | ' Get topic list, worksheet name. | ||
strTopics = DDERequest(intChan1, | strTopics = DDERequest(intChan1, "Selection") | ||
strSheetName = Left(strTopics, InStr(1, strTopics, | strSheetName = Left(strTopics, InStr(1, strTopics, "!") - 1) | ||
' Terminate DDE link. | ' Terminate DDE link. | ||
Line 94: | Line 94: | ||
' Establish link with new worksheet. | ' Establish link with new worksheet. | ||
intChan1 = DDEInitiate( | intChan1 = DDEInitiate("Excel", strSheetName) | ||
For intI = 1 To 10 | For intI = 1 To 10 | ||
' Put some values into | ' Put some values into | ||
DDEPoke intChan1, | DDEPoke intChan1, "R1C" & intI, intI | ||
' first row. | ' first row. | ||
Line 104: | Line 104: | ||
' Make chart. | ' Make chart. | ||
DDEExecute intChan1, | DDEExecute intChan1, "[Select(""R1C1:R1C10"")][New(2,2)]" | ||
' Terminate all links. | ' Terminate all links. | ||
Line 128: | Line 128: | ||
== MORE INFORMATION == | == MORE INFORMATION == | ||
The Microsoft Access 97 Help Topic | The Microsoft Access 97 Help Topic "Convert Access Basic Code to Visual Basic" states the following:<br /> | ||
<pre class="fixed_text"> If you use the DDEInitiate function to open a DDE channel, you can | <pre class="fixed_text"> If you use the DDEInitiate function to open a DDE channel, you can |
Latest revision as of 12:29, 21 July 2020
Article ID: 174498
Article Last Modified on 1/20/2007
APPLIES TO
- Microsoft Access 97 Standard Edition
This article was previously published under Q174498
Moderate: Requires basic macro, coding, and interoperability skills.
SUMMARY
The Microsoft Access 97 Help Topic Example "Dynamic Data Exchange (DDE) Example," which can be displayed by clicking Example on the following topics,
- DDEEXecute Statement - DDEInitiate Function - DDEPoke Statement - DDERequest Function - DDETerminate Statement - DDETerminateAll Statement
contains the following code:
Sub ExcelDDE() Dim intI As Integer, intChan1 As Integer Dim strTopics As String, strResp As String, strSheetName As String On Error Resume Next ' Set up error handling. intChan1 = DDEInitiate("Excel", "System") ' Establish link. If Err Then ' If error occurs, Excel Err = 0 ' may not be running. ' Reset error Shell "C:\Excel\Excel.exe", 1 ' and start spreadsheet. If Err Then Exit Sub ' If another error, exit. ' Establish Spreadsheet link. intChan1 = DDEInitiate("Excel", "System") End If ' Create new worksheet. DDEExecute intChan1, "[New(1)]" ' Get topic list, worksheet name. strTopics = DDERequest(intChan1, "Selection") strSheetName = Left(strTopics, InStr(1, strTopics, "!") - 1) ' Terminate DDE link. DDETerminate intChan1 ' Establish link with new worksheet. intChan1 = DDEInitiate("Excel", strSheetName) For intI = 1 To 10 ' Put some values into DDEPoke intChan1, "R1C" & intI, intI ' first row. Next intI ' Make chart. DDEExecute intChan1, "[Select(""R1C1:R1C10"")][New(2,2)]" ' Terminate all links. DDETerminateAll End Sub
The first line of the code, which reads as follows, is incorrect:
Dim intI As Integer, intChan1 As Integer
Change this line to read as follows:
Dim intI As Long, intChan1 As Long.
This change is necessary when working with 32-bit applications.
MORE INFORMATION
The Microsoft Access 97 Help Topic "Convert Access Basic Code to Visual Basic" states the following:
If you use the DDEInitiate function to open a DDE channel, you can declare the variable that stores the channel number, which is a Long value, as either a Variant or Long value. In versions 1.x and 2.0 of Microsoft Access, the channel number is an Integer value, so you must modify any Declaration statements in your code that create variables of type Integer to store the channel number.
Additional query words: ACC97 inf
Keywords: kbother KB174498