XL98: Error Using XLCALL and SaveAs Functions (192214)



The information in this article applies to:

  • Microsoft Excel 98 Macintosh Edition

This article was previously published under Q192214

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 run; but when it returns control to the XLCALL function, an error occurs.

WORKAROUND

To work around this problem, use any of the following methods.

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. 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. 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.

Modification Type:MajorLast Reviewed:6/17/2005
Keywords:kbbug kbdtacode kbmacro kbnofix KB192214