TheWennerWoman
Active Member
- Joined
- Aug 1, 2019
- Messages
- 301
- Office Version
- 365
- Platform
- Windows
Hello,
I have a load of files in a directory that have data connections. I am currently opening them one by one, right-clicking on the relevant data table and clicking "refresh".
Can I automate this? I have got this which opens the files fine, I just need the next bit to refresh them all.
Many thanks for reading.
I have a load of files in a directory that have data connections. I am currently opening them one by one, right-clicking on the relevant data table and clicking "refresh".
Can I automate this? I have got this which opens the files fine, I just need the next bit to refresh them all.
VBA Code:
Option Explicit
Sub OpenAllFiles()
Dim filpath As String
Dim fso As Scripting.FileSystemObject
Dim fil As Scripting.File
Dim fldr As Scripting.Folder
filpath = "C:\Users\TheWennerWoman\OneDrive - Excalibur\Documents\Daily Control Files"
Set fso = New Scripting.FileSystemObject
Set fldr = fso.GetFolder(filpath)
For Each fil In fldr.Files
Application.Workbooks.Open (fil.Path)
Next fil
End Sub
Many thanks for reading.