我正在尝试将.csv中的数据导入excel以更新数据透视表。这是我们每天必须做多次的事情,所以我试图用这个宏更多地自动化它。这是代码:
Private Sub TestButton_Click()
Dim AspectPath As String
AspectPath = ThisWorkbook.Path & "\Test\Test.csv"
Sheets("Aspect Data").Visible = True
Sheets("Aspect Data").Select
Range("A1").Select
Sheets("Aspect Data").Cells.Clear
With ActiveSheet.QueryTables _
.Add(Connection:="TEXT;" & AspectPath, Destination:=Range("A1"))
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFilePlatform = 850
.TextFileStartRow = 1
.TextFileParseType = xlDelimited
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = False
.TextFileTabDelimiter = False
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = True
.TextFileSpaceDelimiter = False
.TextFileColumnDataTypes = Array(1, 1, 1, 1)
.TextFileTrailingMinusNumbers = True
.Refresh BackgroundQuery:=False
End With
End Sub
工作簿保存在可由整个团队访问的共享Google云端硬盘文件夹中。当我运行宏时,它没有问题。当团队的其他成员尝试时,他们会收到以下错误:VBA Run-time error 1004
我已经搜索了许多其他类似的问题,但我发现的几乎所有解决方案最终都成为文件路径的问题。我知道我的代码不是这样,因为宏在我的计算机上工作正常。我的猜测是它与Google Drive保存/同步的方式有关,但我很难过。