因此,您可以使用如下包装器: Sub ReloadWorkbook(wb As Workbook) Dim app As Application, nm As String Set app = wb.Application 'in case in a different instance of Excel nm = wb.Name wb.UpdateFromFile Set wb = app.Workbooks(nm) End Sub and call ReloadWorkbook wb_readOnly 而不是wb_re...
此外,Workbook对象还有一个HasVBProject属性可以判断是否将工作簿保存为启用宏的工作簿。 ReadOnly属性 其语法为: Workbook对象.ReadOnly 如果工作簿只读,则返回True。 下面的代码当活动工作簿为只读时,将其另存为新的名称。 If ActiveWorkbook.ReadOnly Then ActiveWor...
双击桌面上的Excel快捷方式图表,或者点击桌面左下角开始菜单,找到Excel程序,单击即可打开工作簿。 在VBA中,我们可以使用Workbooks对象的Open方法打开工作簿,其语法为: Workbooks对象.Open(FileName,[UpdateLinks],[ReadOnly],[Format],[Password],[Write...
我在Excel中使用ACE.OLEDB运行sql,并像使用数据库一样使用我的工作表。在我的Pc本地驱动器上,一切都很正常,但一旦我将文件上传到Sharepoint并从那里启动它,我就会收到以下错误: 错误号:-214746725 9错误描述:“无法更新。数据库或对象是read-only.” 我在网上查了一下,发现有些人通过更改连接字符串并在扩展的...
Set exApp=Excel.Application DoEvents exApp.Visible=True ' Set wb=App.Workbooks.Open(Filename:=sfilename,UpdateLinks:=False,ReadOnly:=False,IgnoreReadOnlyRecommended:=true)Set wb=exApp.Workbooks.Open(Filename:=sfilename,ReadOnly:=False)DoEvents ...
' 复制 Sub CopyExcelData() ' 应用 Dim excelApplication As Object Set excelApplication = CreateObject("Excel.Application") ' 路径 Dim path As String path = "X:/xxx/xxx/xxx/exportData.xls" ' 只读方式打开工作簿 Dim wb As Workbook Set wb = excelApplication.Workbooks.Open(path, ReadOnly:=Tr...
Hello Group, We have a lot of Excel files that are saved with "read-Only recommended". I would like to open files with VBA and also capture the click on "Edit Anyway" in code. I ... NikolinoDE Thanks again Nikolino, In the code which Vit has found, is the same statement I ...
Sub a() Dim mypath As String Dim myfile As String mypath = "d:\123\" myfile = "a.xls" Workbooks.Open mypath & myfile, , TrueEnd Sub 在OPEN中的第三个参数。=TRUE表示,为只读方式打开。测试OK!Workbooks.Open (MyPath ...
Excel VBA(宏):添加宏 写在前面: 1、编写宏,打开VBA,双击ThisWorkbook对当前工作薄进行编写宏;双击Sheet1,对整个sheet编写宏; 或者创建模块,在模块里,编写、调试代码。 打开VBA的方法见第一讲,结合常用窗口进行编写、调试。 2、部分对象有提示,如Dim a As,敲击空格后有提示。
Workbooks.Open Filename:="C:\excelvba\excel_test.xlsx", WriteResPassword:="password" End Sub '以只读模式打开加密文件 Sub openExcelWorkbookWithWritePassword() Workbooks.Open Filename:="C:\excelvba\excel_test.xlsx", Passwor:="password", ReadOnly:=True ...