更新:2007 年 11 月
在另一个文件中保存对工作表所做的更改。
命名空间: Microsoft.Office.Tools.Excel
程序集: Microsoft.Office.Tools.Excel.v9.0(在 Microsoft.Office.Tools.Excel.v9.0.dll 中)
语法
声明
Public Sub SaveAs ( _
Filename As String, _
FileFormat As Object, _
Password As Object, _
WriteResPassword As Object, _
ReadOnlyRecommended As Object, _
CreateBackup As Object, _
AddToMru As Object, _
TextCodepage As Object, _
TextVisualLayout As Object, _
Local As Object _
)
用法
Dim instance As Worksheet
Dim Filename As String
Dim FileFormat As Object
Dim Password As Object
Dim WriteResPassword As Object
Dim ReadOnlyRecommended As Object
Dim CreateBackup As Object
Dim AddToMru As Object
Dim TextCodepage As Object
Dim TextVisualLayout As Object
Dim Local As Object
instance.SaveAs(Filename, FileFormat, _
Password, WriteResPassword, ReadOnlyRecommended, _
CreateBackup, AddToMru, TextCodepage, _
TextVisualLayout, Local)
public void SaveAs(
string Filename,
Object FileFormat,
Object Password,
Object WriteResPassword,
Object ReadOnlyRecommended,
Object CreateBackup,
Object AddToMru,
Object TextCodepage,
Object TextVisualLayout,
Object Local
)
参数
Filename
类型:System.String要保存的文件的名称。可以包含完整路径;否则,Microsoft Office Excel 将文件保存在当前文件夹中。
FileFormat
类型:System.Object保存文件时要使用的文件格式。有关有效选项的列表,请参见 FileFormat 属性。对于现有文件,默认格式为最后一种指定文件格式;对于新文件,默认格式为所用 Excel 版本的格式。
Password
类型:System.Object一个区分大小写的字符串(不超过 15 个字符),指示为文件指定的保护密码。
WriteResPassword
类型:System.Object文件的写保护密码。如果保存文件时指定了密码,但打开文件时没有提供密码,则该文件以只读方式打开。
ReadOnlyRecommended
类型:System.Object如果为 true,则在打开该文件时显示一条消息,建议以只读方式打开该文件。
CreateBackup
类型:System.Object如果为 true,则创建备份文件。
AddToMru
类型:System.Object如果为 true,则将工作簿添加到最近使用的文件列表中。默认值为 false。
TextCodepage
类型:System.Object在美国英语版本的 Excel 中未使用。
TextVisualLayout
类型:System.Object在美国英语版本的 Excel 中未使用。
Local
类型:System.Object如果为 true,则针对 Excel 语言保存文件(包括控制面板设置);如果为 false(默认),则针对 Visual Basic for Applications (VBA) 语言保存文件。
备注
可选参数
有关可选参数的信息,请参见了解 Office 解决方案中的可选参数。
示例
下面的代码示例使用 SaveAs 方法保存当前工作表的新副本。
此示例针对的是文档级自定义项。
Private Sub SaveWorksheetCopy()
Me.SaveAs(Me.Name + ".copy.xls")
End Sub
private void SaveWorksheetCopy()
{
this.SaveAs(this.Name + ".copy.xls", missing, missing, missing,
missing, missing, missing, missing, missing, missing);
}
权限
- 对直接调用方的完全信任。此成员不能由部分信任的代码使用。有关更多信息,请参见通过部分受信任的代码使用库。