MSQuery: DDE Command Fetch.Unadvise Does Not Break Link

Last reviewed: September 12, 1996
Article ID: Q149875
The information in this article applies to:
  • Microsoft Query for Windows, version 1.0
  • Microsoft Query for Windows 95, version 2.0

SYMPTOMS

When you use the Microsoft Query Fetch.Unadvise DDE command to break a link that was created with Fetch.Advise, the link may not be broken.

WORKAROUND

To work around this problem, close each query window when you are finished working with it and then create a new one with the Microsoft Query DDE command OPEN. 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 support engineers 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:

  1. Start Microsoft Query.

  2. Create a data source with the name of "Nwind" (without the quotation marks), using the dBASE files included with Microsoft Excel.

  3. In the workbook that contains the macro code, make sure there is a worksheet named Sheet1.

  4. Type the following procedure into a module sheet:

       Sub Using_FetchAdvise()
       Dim NumRows
       Dim NumCols
    
       'create a channel to Query
       chan = DDEInitiate("MSQuery", "System")
    
       'log onto the NWind data source
       DDEExecute chan, "[Logon('nwind')]"
    
       'issue a select statement
       DDEExecute chan, "[Open('Select * From Customer')]"
    
       'request the number of rows and columns in the result set
       NumRows = DDERequest(chan, "NumRows")
       NumCols = DDERequest(chan, "NumCols")
    
       'return the data to the Excel sheet with a hot link
       DDEExecute chan, "[Fetch.Advise('Excel','Sheet1','R1C1:R" & NumRows(1) _
       & "C" & NumCols(1) & "','All/Headers')]"
    
       'stops the macro
       'at this point you can go into Query and change the data so that it will
       'update the data on sheet1
       'Press F5 to continue the macro
       Stop
    
       'close the query window
       DDEExecute chan, "[Close()]"
    
       'issue a select statement
       DDEExecute chan, "[Open('select * from customer')]"
    
       'request the number of rows and columns in the result set
       NumRows = DDERequest(chan, "NumRows")
       NumCols = DDERequest(chan, "NumCols")
    
       'return the data to the Microsoft Excel sheet with a hot link
       DDEExecute chan, "[Fetch.Advise('Excel','Sheet1','R1C1:R" & NumRows(1) _
       & "C" & NumCols(1) & "','All/Headers')]"
    
       'close the query window
       DDEExecute chan, "[Close()]"
    
       'logoff of NWind
       DDEExecute chan, "[Logoff('NWind')]"
    
       'terminate the DDE channel
       DDETerminate chan
    
       End Sub
    
    

  5. Run the macro.

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 Fetch.UnAdvise, click the Search button in Microsoft Query Help and type:

   Fetch


KBCategory: kbbug kbprg kbcode kbtool
KBSubcategory: xlquery

Additional reference words: 1.00 2.00 dynamic programmatically programming



THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: September 12, 1996
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.