共用方式為


WorksheetBase.SaveAs Method

Definition

Saves changes to the worksheet in a different file.

public void SaveAs (string filename, object fileFormat, object password, object writeResPassword, object readOnlyRecommended, object createBackup, object addToMru, object textCodepage, object textVisualLayout, object local);
member this.SaveAs : string * obj * obj * obj * obj * obj * obj * obj * obj * obj -> unit
Public Sub SaveAs (filename As String, Optional fileFormat As Object, Optional password As Object, Optional writeResPassword As Object, Optional readOnlyRecommended As Object, Optional createBackup As Object, Optional addToMru As Object, Optional textCodepage As Object, Optional textVisualLayout As Object, Optional local As Object)

Parameters

filename
String

The name of the file to be saved. You can include a full path; if you do not, Microsoft Office Excel saves the file in the current folder.

fileFormat
Object

The file format to use when you save the file. For a list of valid choices, see the FileFormat property. For an existing file, the default format is the last file format specified; for a new file, the default is the format of the version of Excel being used.

password
Object

A case-sensitive string (no more than 15 characters) that indicates the protection password to be given to the file.

writeResPassword
Object

The write-reservation password for this file. If a file is saved with the password and the password is not supplied when the file is opened, the file is opened as read-only.

readOnlyRecommended
Object

true to display a message when the file is opened, recommending that the file be opened as read-only.

createBackup
Object

true to create a backup file.

addToMru
Object

true to add this workbook to the list of recently used files. The default value is false.

textCodepage
Object

Not used in U.S. English Excel.

textVisualLayout
Object

Not used in U.S. English Excel.

local
Object

true saves files against the language of Excel (including control panel settings); false (default) saves files against the language of Visual Basic for Applications (VBA).

Examples

The following code example uses the SaveAs method to save a new copy of the current worksheet.

This example is for a document-level customization.

private void SaveWorksheetCopy()
{
    this.SaveAs(this.Name + ".copy.xlsx");
}
Private Sub SaveWorksheetCopy()
    Me.SaveAs(Me.Name + ".copy.xlsx")
End Sub

Remarks

Optional Parameters

For information on optional parameters, see Optional Parameters in Office Solutions.

Applies to