MSQuery: DDE Activate Command Does Not Activate Window
ID: Q147217
|
The information in this article applies to:
-
Microsoft Query for Windows 95, version 2.0
SYMPTOMS
When you use the Microsoft Query DDE command, Activate, to activate a query
window, the window may not be activated.
RESOLUTION
To work around the problem, close out each query window when you are
finished working with it and then create a new one with the OPEN command.
The following macro is an example of using this method.
Microsoft provides examples of Visual Basic for Applications procedures for
illustration only, without warranty either expressed or implied, including,
but not limited to the implied warranties of merchantability and/or fitness
for a particular purpose. The Visual Basic procedures in this article are
provided 'as is' and Microsoft does not guarantee that they can be used in
all situations. While Microsoft Product Support Services (PSS) professionals
can help explain the functionality of a particular macro, they will not
modify these examples to provide added functionality, nor will they help
you construct macros to meet your specific needs. If you have limited
programming experience, you may want to consult one of the Microsoft
Solution Providers. Solution Providers offer a wide range of fee-based
services, including creating custom macros. For more information about
Microsoft Solution Providers, call Microsoft Customer Information Service
at (800) 426-9400.
To run the macro do the following:
- Start Microsoft Query.
- Create a data source with the name NWind, using the dBASE files included with Microsoft Excel.
- In the workbook that contains the macro code, make sure there are
two sheets named sheet1 and sheet2.
- Type the following procedure:
Sub Open_And_Close_Windows()
Dim chan as integer
Dim NumRows As Variant
Dim NumCols As Variant
'Initiate a channel to MSQuery.
chan = DDEInitiate("MSQuery","System")
'Log on to the NWind datasource.
DDEExecute chan, "[Logon('NWind')]"
'Execute a SQL statement.
DDEExecute chan,"[Open('Select * From Customer')]"
'Request the number of rows in the data set.
NumRows = DDERequest(chan,"NumRows")
'Request the number of columns in the data.
NumCols = DDERequest(chan,"NumCols")
'Return the data to sheet1.
DDEExecute chan, "[Fetch('Excel', 'Sheet1', 'R1C1:R" _
& NumRows(1) & "C" & NumCols(1) & "', 'All')]"
'Close the current query window.
DDEExecute chan, "[Close()]"
'Create a new query window.
DDEexecute chan, "[Open('Select * From Employee')]"
'Request the number of rows in the data set.
NumRows = DDERequest(chan,"NumRows")
'Request the number of columns in the data.
NumCols = DDERequest(chan,"NumCols")
'Return the data to sheet2.
DDEExecute chan, "[Fetch('Excel', 'Sheet2', 'R1C1:R" _
& NumRows(1) & "C" & NumCols(1) & "', 'All')]"
'Logoff the datasource.
DDEExecute chan, "[Logoff('NWind')]"
'Tterminate the channel.
DDETerminate chan
End Sub
STATUS
Microsoft has confirmed this to be a problem in the Microsoft products
listed at the beginning of this article. We are researching this problem
and will post new information here in the Microsoft Knowledge Base as it
becomes available.
REFERENCES
"Microsoft Query User's Guide," version 1.0, Chapter 9, "Using Dynamic Data
Exchange with Microsoft Query"
For more information about DDE, on the Microsoft Query Help menu, click
Contents and under References, select "DDE Commands."
Additional query words:
Keywords : xlquery xlwin
Version : WINDOWS:2.0
Platform : WINDOWS
Issue type :
|