zoukankan      html  css  js  c++  java
  • [转]Workbook.SaveAs method (Excel) Password

    本文转自:https://docs.microsoft.com/en-us/office/vba/api/excel.workbook.saveas

    Saves changes to the workbook in a different file.

    Syntax

    expressionSaveAs_FileName_ , _FileFormat_ , _Password_ , _WriteResPassword_ , _ReadOnlyRecommended_ , _CreateBackup_ , _AccessMode_ , _ConflictResolution_ , _AddToMru_ , _TextCodepage_ , _TextVisualLayout_ , _Local_ )

    expression A variable that represents a Workbook object.

    Parameters

    NameRequired/OptionalData typeDescription
    FileName Optional Variant A string that indicates the name of the file to be saved. You can include a full path; if you don't, Microsoft Excel saves the file in the current folder.
    FileFormat Optional Variant The file format to use when you save the file. For a list of valid choices, see the XlFileFormat enumeration. 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 Optional Variant A case-sensitive string (no more than 15 characters) that indicates the protection password to be given to the file.
    WriteResPassword Optional Variant A string that indicates the write-reservation password for this file. If a file is saved with the password and the password isn't supplied when the file is opened, the file is opened as read-only.
    ReadOnlyRecommended Optional Variant True to display a message when the file is opened, recommending that the file be opened as read-only.
    CreateBackup Optional Variant True to create a backup file.
    AccessMode Optional XlSaveAsAccessMode The access mode for the workbook.
    ConflictResolution Optional XlSaveConflictResolution An XlSaveConflictResolution value that determines how the method resolves a conflict while saving the workbook. If set to xlUserResolution, the conflict-resolution dialog box is displayed. If set to xlLocalSessionChanges, the local user's changes are automatically accepted. If set to xlOtherSessionChanges, the changes from other sessions are automatically accepted instead of the local user's changes. If this argument is omitted, the conflict-resolution dialog box is displayed.
    AddToMru Optional Variant True to add this workbook to the list of recently used files. The default value is False.
    TextCodepage Optional Variant Ignored for all languages in Microsoft Excel.
    Note
    When Excel saves a workbook to one of the CSV or text formats, which are specified by using the FileFormat parameter, it uses the code page that corresponds to the language for the system locale in use on the current computer. This system setting is available in the Control Panel, by clicking Region and Language, clicking theLocation tab, under Current location.
    TextVisualLayout Optional Variant Ignored for all languages in Microsoft Excel.
    Note
    When Excel saves a workbook to one of the CSV or text formats, which are specified by using the FileFormat parameter, it saves these formats in logical layout. If left-to-right (LTR) text is embedded within right-to-left (RTL) text in the file, or vice versa, logical layout saves the contents of the file in the correct reading order for all languages in the file without regard to direction. When an application opens the file, each run of LTR or RTL characters are rendered in the correct direction according to the character value ranges within the code page. (Unless an application that is designed to display the exact memory layout of the file, such as a debugger or editor, is used to open the file.)
    Local Optional Variant True saves files against the language of Microsoft Excel (including control panel settings). False (default) saves files against the language of Visual Basic for Applications (VBA) (which is typically US English unless the VBA project where Workbooks.Open is run from is an old internationalized XL5/95 VBA project).

    Remarks

    Use strong passwords that combine upper- and lowercase letters, numbers, and symbols. Weak passwords don't mix these elements. Strong password: Y6dh!et5. Weak password: House27. Use a strong password that you can remember so that you don't have to write it down

    Example

    This example creates a new workbook, prompts the user for a file name, and then saves the workbook.

    VB
    Set NewBook = Workbooks.Add 
    Do 
        fName = Application.GetSaveAsFilename 
    Loop Until fName <> False 
    NewBook.SaveAs Filename:=fName
    

    See also

    Workbook Object

  • 相关阅读:
    你最喜欢的程序员漫画
    编程名言名句
    查看一个数是不是2的n次方
    程序员需要有多懒 ?- cocos2d-x 数学函数、常用宏粗整理
    C++中string、int、char之间转换
    cocos2d-x 中使用 srand((unsigned)time(NULL))重新设置一个随机种子
    ASP.NET MVC SignalR 配合VUE
    VS Visual Studio光标无法自动到行尾,点哪里就在哪里解决办法
    .NET Core Entity Framework 代码优先配置
    Image Bitmap转MemoryStream后,上传遇到问题,报Index异常
  • 原文地址:https://www.cnblogs.com/freeliver54/p/10847617.html
Copyright © 2011-2022 走看看