首页 > 解决方案 > 将代码从 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 的现有文件,则代码可以工作 - 但这不是我需要实现的

标签: excelvbamacos

解决方案


推荐阅读