excel - 将代码从 Excel 2011 更新到 Excel 2019
问题描述
我们在 microsoft Excel 2011 中使用了一些 VBA 代码,很长一段时间都没有出现任何错误。如果升级到 Office 2019,我们正在处理中,但 VBACode 不断给我错误。例如,当使用下面显示的非常简单的代码将当前文件保存为 WRS.xls
我尝试将文件另存为 .xlsm
Private Sub CommandButton14_Click()
UserForm1.Hide
ChDir "/Volumes/frontoffice/Trading Activity"
ActiveWorkbook.SaveAs Filename:="/Volumes/frontoffice/Trading Activity/WRS.xls" _
, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False
Application.Run "WRS.xls!Back_to_Switcboard"
End Sub
我得到一个
运行时错误 1004 无法访问只读文档消息
如果我在执行代码之前删除名为 WRS.xls 的现有文件,则代码可以工作 - 但这不是我需要实现的
解决方案
推荐阅读
- react-native - 如何找出所有应用程序的深层链接路径?
- php - SQLSTATE[HY000]: 一般错误: 21 bad parameter or other API misuse - in pyrocms
- c# - 循环参考/保留周期
- angular - 导出 *(星号)在 Angular/Typescript 中是什么意思
- scala - 在基于 scala 的 spark 结构化流程序中执行基于 python 的模型
- python - 如何在python中保持随机生成的矩阵常数?
- javascript - 使用 momentJS 在 Jasmin 单元测试中更改时区
- c# - 比较不同机器上的字符串哈希
- c - 二维数组动态分配中的分段错误
- c# - 如何按列对数据集进行排序