![](/img/trans.png)
[英]How can I use VBScript to effectively refresh the external data of several Excel spreadsheets?
[英]refresh the external data of several Excel spreadsheets?
我從這里的一個用戶那里得到了這段代碼,但是我不確定是否允許我發布他們的問題,因為我在問發布的那個代碼的另一個問題...抱歉,我是新來的...
這是一個問題:
如何使用VBScript有效刷新幾個Excel電子表格的外部數據?
這是代碼:
Sub RefreshAllExcelInFolder()
Dim fso
Dim ObjFolder
Dim ObjFiles
Dim ObjFile
Dim objExcel
'Creating File System Object
Set fso = CreateObject("Scripting.FileSystemObject")
'Getting the Folder Object
Set ObjFolder = fso.GetFolder("S:\Finance & Performance\IM&T\Information\Surgicaldir\18 Weeks\18wksPTL\validation")
'Getting the list of Files
Set ObjFiles = ObjFolder.Files
'On Error Resume Next
For Each ObjFile In ObjFiles
If LCase(Right(ObjFile.Name, 5)) = ".xlsx" Or LCase(Right(ObjFile.Name, 4)) = ".xls" Then
Workbooks.Open(ObjFile).Activate
RefreshAllData
End If
Next
End Sub
Sub RefreshAllData()
ActiveWorkbook.RefreshAll
ActiveWorkbook.Save
ActiveWorkbook.Close
MsgBox ("Going back In")
End Sub
我收到此消息,按“確定”后可以正常使用-但是有什么辦法可以避免收到此消息? 此操作將取消掛起的刷新數據命令。 繼續? 謝謝麗茲
轉到每個連接,選擇“屬性”,然后取消選擇“背景刷新”選項。
我相信禁用此選項將迫使您的腳本等待刷新所有連接后再繼續。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.