The information in this article applies to:
SUMMARYIn Microsoft Excel, you can use a Visual Basic for Applications macro to run other Windows and MS-DOS applications and procedures. The macro code in Microsoft Excel continues to execute even after the external procedure has been initiated. You must write code to handle delays if Microsoft Excel is to wait for the output from the outside procedure. MORE INFORMATIONMicrosoft provides programming examples 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. This article assumes that you
are familiar with the programming language being demonstrated and the tools used to
create and debug procedures. Microsoft support professionals can help explain the functionality
of a particular procedure, but they will not modify these examples to provide added
functionality or construct procedures to meet your specific needs. If you have limited
programming experience, you may want to contact a Microsoft Certified Solution Provider
or the Microsoft fee-based consulting line at (800) 936-5200. For more information about
Microsoft Certified Solution Providers, please see the following page on the World Wide Web:
http://www.microsoft.com/mcsp/For more information about the support options available from Microsoft, please see the following page on the World Wide Web: http://www.microsoft.com/support/supportnet/overview/overview.asp Creating the ModuleBefore you use the examples in this article, follow these steps:
Example 1: Creating a FlagFor the macro code in example 1 to work correctly, you need to make your custom application create a flag when it has completed execution. In the following example your custom application should create a text file at C:\Flag.txt to act as this flag.
Example 2: Using an Intermediate File to Avoid a Sharing ViolationThis example uses an intermediate file to allow the MS-DOS DIR command to complete and close the output before Microsoft Excel attempts to open it. If this method were not used, the Workbooks.Open method would generate a sharing violation by attempting to open the output while it was still being written.While the example below illustrates one use of this procedure, you could apply the same method to any MS-DOS or Windows application that generates an output file that can be read by Microsoft Excel.
REFERENCES
For additional information, please see the following articles in the
Microsoft Knowledge Base: Q129796 How to Determine When a Shelled 32-bit Process Has Terminated Additional query words: pause yield stop external subprogram dos macro call console batch script
Keywords : kbcode kbprg kbdtacode KbVBA |
Last Reviewed: July 6, 1999 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |