zoukankan      html  css  js  c++  java
  • SaveAs in Excel 20072010

    You see a lot of old SaveAs code that does not specify the FileFormat
    parameter. In Excel versions before Excel 2007, code without this parameter
    will not cause too many problems because Excel will use the current FileFormat
    of the existing file -- and the default FileFormat for new files is a normal workbook.

    But because there are so many new file formats in Excel 2007-2010, we shouldn't
    use code like this that does not specify the FileFormat parameter.

    In Excel 2007-2010, SaveAs requires you to provide both the FileFormat parameter
    and the correct file extension.

    For example, in Excel 2007-2010, this will fail if the ActiveWorkbook is not an xlsm file
    ActiveWorkbook.SaveAs "C:\ron.xlsm"

    This code will always work
    ActiveWorkbook.SaveAs "C:\ron.xlsm", fileformat:=52
    ' 52 = xlOpenXMLWorkbookMacroEnabled = xlsm (with macro's in 2007-2010)


    These are the main file formats in Excel 2007-2010:

    51 = xlOpenXMLWorkbook (without macro's in 2007-2010, xlsx)
    52 = xlOpenXMLWorkbookMacroEnabled (with or without macro's in 2007-2010, xlsm)
    50 = xlExcel12 (Excel Binary Workbook in 2007-2010 with or without macro's, xlsb)
    56 = xlExcel8 (97-2003 format in Excel 2007-2010, xls)

    Note: I always use the FileFormat numbers instead of the defined constants
    in my code so that it will compile OK when I copy the code into an Excel
    97-2003 workbook. (For example, Excel 97-2003 won't know what the
    xlOpenXMLWorkbookMacroEnabled constant is.)

  • 相关阅读:
    python3.6虚拟环境
    安装VMwareTools
    Vsftpd配置(Centos7)
    Sftp配置
    权限问题
    Zabbix5.0微信报警
    K8s Scheduler 在调度 pod 过程中遗漏部分节点的问题排查
    Getting Started and Beyond|云原生应用负载均衡选型指南
    混部之殇-论云原生资源隔离技术之CPU隔离(一)
    云原生技术开放日PPT大放送 | 五星级的云原生开发体验
  • 原文地址:https://www.cnblogs.com/silva/p/2008732.html
Copyright © 2011-2022 走看看