I got this code from a user on here but i wasnt sure if i was allowed to post on their question as i was asking another question of that code that was posted... sorry i am new...
here was the question:
How can I use VBScript to effectively refresh the external data of several Excel spreadsheets?
here was the code:
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
i get this message which after pressing OK works perfect - but is there any way not to get this message? this action will cancel a pending refresh data command. continue? thanks liz