Excel: Running FLATFILE.XLA from a User-Defined Macro

Last reviewed: September 2, 1997
Article ID: Q78308
The information in this article applies to:
  • Microsoft Excel for Windows, versions 3.0, 4.0 and 4.0a

SUMMARY

In Microsoft Excel, the FLATFILE.XLA add-in file supplies a macro that allows you to import data from a text file to a worksheet, and a second macro that allows you to export data from a worksheet to a text file. Normally these features are accessed from menu options that the add-in supplies. To run the data export macro from within a user-defined macro sheet, you must make a slight modification.

MORE INFORMATION

To execute the Data Export command from a user-defined macro, the following formula is used:

   =FLATFILE.XLA!MCP01.FixedFieldExport()

To execute the Data Smart Parse command from a user-defined macro, the following formula is used:

   =FLATFILE.XLA!MCP05.SmartParse()

If you attempt to export data from a spreadsheet to a file by calling the FLATFILE.XLA data export macro from within a user-defined macro, the user-defined macro will halt. This is because the FLATFILE.XLA data export macro ends with a HALT statement rather than a RETURN statement. The HALT command prevents the data export macro from returning control to the macro that called it.

WORKAROUND

The HALT statement is contained on a cell of FLATFILE.XLA. You can replace it with a RETURN statement. Do the following:

  1. Hold the SHIFT key down as you open FLATFILE.XLA. This makes the file available for editing. If the file is hidden, choose Unhide from the Window menu and select it from the list.

  2. Select the cell containing the HALT statement. This will be on cell B47 in version 3.0, B82 in versions 4.0 and 4.0a.

  3. Replace "=HALT()" with "=RETURN()" (without the quotation marks).

You should make a backup of the original FLATFILE.XLA prior to making any changes.

REFERENCES

"Microsoft Excel Function Reference," version 4.0, pages 216, 363

"Microsoft Excel Function Reference," version 3.0, pages 120, 200

"Microsoft Excel User's Guide 2," version 4.0, pages 151, 152, 199

"Microsoft Excel User's Guide," version 3.0, page 683-684


Additional query words: 3.0 3.00 4.0 4.00 4.0a 4.00a
Keywords : PgmHowTo PgmOthr


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 2, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.