Microsoft KB Archive/157721

= How To Determine FileFormat Values for Excel SaveAs Method =

Article ID: 157721

Article Last Modified on 7/1/2004

-

APPLIES TO


 * Microsoft Visual FoxPro 3.0 Standard Edition
 * Microsoft Visual FoxPro 3.0b Standard Edition
 * Microsoft Visual FoxPro 5.0 Standard Edition
 * Microsoft Visual FoxPro 6.0 Professional Edition

-



This article was previously published under Q157721



SUMMARY
Visual Basic for Excel Help often specifies constant names rather than values to be used in calling object methods. When performing OLE Automation from Visual FoxPro, FoxPro does not understand these constants and, therefore, requires their initial values.

Below are the steps used to determine what the constant value is for a specific file format to be used for the FileFormat portion of the SaveAs method.



MORE INFORMATION
 Create a worksheet in Excel and save it in the format that you want. Make sure that you close the file before continuing.  Issue the following commands in Visual FoxPro: * First get an object reference to the Excel application oXL = CREATEOBJECT("Excel.Application") && starts excel

* Open the worksheet created in step 1 (be sure to include     * the full path and file name      oXL.WorkBooks.Add("myfile.xls")

* Retrieve the FileFormat nFileFormat = oXL.WorkBooks(1).FileFormat

* Save the file under a new name with the same format oXL.WorkBooks(1).SaveAs("new.xls",nFileFormat)

* Quit Excel oXL.Quit

* Release the object reference RELEASE oXL 

Keywords: kbhowto kbinterop KB157721

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.