Error Using XLCALL and SaveAs Functions

This article was previously published under Q126094
This article has been archived. It is offered "as is" and will no longer be updated.
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.
You receive an error at the cell that contains the XLCALL function if theMicrosoft Excel macro that is called contains a SaveAs command, and eitherof 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 run; but when itreturns control to the XLCALL function, an error occurs.
Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to 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 requirements. To work around this problem, use any of the following methods.

Method 1

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

Method 2

If the SaveAs command saves another workbook, switch to the workbook andworksheet that contains the {XLCALL} function before it leaves the subprocedure. The following procedure, which is called from Test.xls, opens anew workbook and saves it as Book.xls. It then switches to the worksheet inwhich 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				
Microsoft has confirmed this to be a problem in the Microsoft productslisted at the beginning of this article.
The XLCALL command is used to call a Microsoft Excel macro or module from aLotus 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. Forexample, this will run a Visual Basic for Applications macro called Macro1located in Module1 of the active workbook.
{XLCALL Module1.Macro1}
"Microsoft Excel User's Guide," version 5.0, Chapter 3, "MicrosoftExcel for Windows Runs 1-2-3 Macros"
8.00 97 XL97 XL7 XL5 XL

Article ID: 126094 - Last Review: 09/13/2013 20:21:13 - Revision: 2.1

  • Microsoft Excel 97 Standard Edition
  • Microsoft Excel 95 Standard Edition
  • Microsoft Excel 5.0 Standard Edition
  • kbnosurvey kbarchive kbbug kbdtacode kbmacro kbpending kbprogramming KB126094