TheWennerWoman
Active Member
- Joined
- Aug 1, 2019
- Messages
- 303
- Office Version
- 365
- Platform
- Windows
Hello,
Is it possible to tweak this code (that works perfectly) to ensure that when each file is opened that it's maximized?
Thank you for reading as always.
Is it possible to tweak this code (that works perfectly) to ensure that when each file is opened that it's maximized?
VBA Code:
Sub OpenAllFiles()
Dim filpath As String
Dim fso As Scripting.FileSystemObject
Dim fil As Scripting.File
Dim fldr As Scripting.Folder
Dim a As Long
a = 0
filpath = "C:\Users\Noddy\OneDrive - Excalibur Ltd\Documents\Daily\"
Set fso = New Scripting.FileSystemObject
Set fldr = fso.GetFolder(filpath)
Application.DisplayAlerts = False
On Error Resume Next
For Each fil In fldr.Files
If fil.Size >= 5000 And fil.Size < 50000 Then
With Application.Workbooks.Open(fil.Path)
.RefreshAll
' .Close False
End With
a = a + 1
End If
Next fil
ThisWorkbook.Worksheets("Sheet1").Range("F3").Value = Now()
ThisWorkbook.Worksheets("Sheet1").Range("G3").Value = a
End Sub
Thank you for reading as always.