Excel编译错误:无法分配给只读属性

时间:2016-08-08 15:50:10

标签: excel excel-vba vba

我在Excel中收到有关使用以下代码分配给只读属性的错误:

1    Sub GetSheets()
2    Path = "C:WHERE MY DOCUMENTS ARE KEPT"
3    Filename = Dir(Path & "*.CSV")
4      Do While Filename <> ""
5      Workbooks.Open Filename:=Path & Filename, ReadOnly:=True
6         For Each Sheet In ActiveWorkbook.Sheets
7         Sheet.Copy After:=ThisWorkbook.Sheets(1)
8      Next Sheet
9         Workbooks(Filename).Close
10         Filename = Dir()
11      Loop
12    End Sub

1 个答案:

答案 0 :(得分:3)

我猜你在limits模块中有发布的代码?

ThisWorkbook表示工作簿本身,它具有内置(只读)ThisWorkbook属性。

Path重命名为(例如)Path,您应该没问题。

myPath