XL: Error Using XLCALL and SaveAs Functions

Last reviewed: February 2, 1998
Article ID: Q126094
The information in this article applies to:
  • Microsoft Excel 98 Macintosh Edition
  • Microsoft Excel 97 for Windows
  • Microsoft Excel for Windows 95, versions 7.0, 7.0a
  • Microsoft Excel for Windows, versions 5.0, 5.0c
  • Microsoft Excel for the Macintosh, versions 5.0, 5.0a

SYMPTOMS

In Microsoft Excel, you may receive a macro error when you use the XLCALL function in a Lotus 1-2-3 macro to call a Microsoft Excel Visual Basic for Applications module that contains the SaveAs function.

CAUSE

You receive an error at the cell that contains the XLCALL function if the Microsoft Excel macro that is called contains a SaveAs command, and either of the following conditions occurs:

  • The SaveAs command saves the workbook that contains the XLCALL under a different name.

        -or-
    
  • The SaveAs command saves another workbook.

The Microsoft Excel procedure that is called is executed; but when it returns control to the XLCALL function, an error occurs.

WORKAROUNDS

Method 1

If the SaveAs command saves the workbook that contains the XLCALL function under a different name, modify the SaveAs function so that the module saves the workbook containing the XLCALL function under the same name.

Method 2

Microsoft 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 engineers 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 the Microsoft fee-based consulting line at (800) 936-5200. For more information about the support options available from Microsoft, please see the following page on the World Wide Web:

   http://www.microsoft.com/supportnet/refguide/

If the SaveAs command saves another workbook, switch to the workbook and worksheet that contains the {XLCALL} function before it leaves the sub procedure. The following procedure, which is called from Test.xls, opens a new workbook and saves it as Book.xls. It then switches to the worksheet in which the XLCALL command is located (Test.xls).

   Sub SheetSave()
       'Open new workbook
       Workbooks.Add

       'Save new workbook as Book.xls
       ActiveWorkbook.SaveAs FileName:="Book.xls", FileFormat:=xlNormal

       'Activate Test.xls, which is where the XLCALL
       'command is located
       Workbooks("Test.xls").Activate
       Worksheets("A").Activate
   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 more information here in the Microsoft Knowledge Base as it becomes available.

MORE INFORMATION

The XLCALL command is used to call a Microsoft Excel macro or module from a Lotus 1-2-3 macro. The syntax for this command is as follows:

   {XLCALL macro_name}

Where macro_name is the name of the Microsoft Excel macro being called. For example, this will run a Visual Basic for Applications macro called Macro1 located in Module1 of the active workbook.

   {XLCALL Module1.Macro1}

REFERENCES

"Microsoft Excel User's Guide," version 5.0, Chapter 3, "Microsoft Excel for Windows Runs 1-2-3 Macros"


Additional query words: 5.00 7.00 8.00 97 98 XL98 XL97 XL7 XL5
Keywords : xlvbainfo kbcode kbmacro kbprg
Version : WINDOWS:5.0,5.0c,7.0,7.0a,97; MACINTOSH:5.0,98
Platform : MACINTOSH WINDOWS


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