excel - 如何使用 VBA 刷新查询表
问题描述
我正在使用查询表将 csv 文件调用到特定工作表。我希望每 30 秒刷新一次。我有以下代码可以在 csv 文件中调用,但我看不到让刷新工作。代码运行,将 csv 数据放入正确的工作表中,但似乎没有刷新 有人可以指出我的写入方向吗?这有点尴尬,因为我在 Python 和 MATLAB 中编写代码,但使用 VBA 我很难掌握它。谢谢你的帮助
Dim fileName As String
fileName = "C:\Users\aofarrell\Desktop\Book1.csv"
With ThisWorkbook.Sheets("Sheet8").QueryTables.Add(Connection:= _
"TEXT;" & fileName, Destination:=Range("$A$1"))
'.Name = "CAPTURE"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0.5
.TextFilePromptOnRefresh = False
.TextFilePlatform = 437
.TextFileStartRow = 1
.TextFileParseType = xlDelimited
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = False
.TextFileTabDelimiter = True
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = True
.TextFileSpaceDelimiter = False
.TextFileColumnDataTypes = Array(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1)
.TextFileTrailingMinusNumbers = True
.Refresh BackgroundQuery:=True
End With
End Sub
解决方案
推荐阅读
- android - Flutter 应用仅支持 Playstore 中的 5,759 台设备。什么是应用程序问题?
- python - 如何将emoji unicode转换为emoji?
- java - 在VSC中选择一个Java项目的主类
- ios - Admob 搜索未在其搜索中显示我的应用
- performance - Numba 快速数学不会提高速度
- three.js - 即使在 needsupdate 设置为 true 后,BufferGeometry 也不会更新
- node.js - Nodejs没有在for循环中将数据更新到mongodb
- bash - Bash - 循环文件
- php - 将 MonthNAME 和 Number 添加到 mysql 查询
- flutter - 当 ListView.builder 顶部附近的项目高度被缓存但已更改时,如何从 animateTo 获得正常行为?