beginvbaanalyst
Board Regular
- Joined
- Jan 28, 2020
- Messages
- 139
- Office Version
- 365
- Platform
- Windows
Hi everyone,
I've been having trouble figuring out how to open a closed excel document without using the direct closed path.
We update this file on occasion when something breaks so I need the macro to understand when a new file has been created with the same text.
My practice macro build is below
My Macro breaks at the FileName and I can't figure out why.
Is anyone able to help?
Thank you.
I've been having trouble figuring out how to open a closed excel document without using the direct closed path.
We update this file on occasion when something breaks so I need the macro to understand when a new file has been created with the same text.
My practice macro build is below
VBA Code:
Dim ListScript As String
Dim Path1 As String
Dim Path2 As String
Dim ListFile As String
Dim FileName As String
Path1 = "A:\Scripts Library\Script Execution\Execution Templates\ASSORTMENT\"
Path2 = "WSM3_LISTING.xlsx\"
ListFile = Path1 & Path2
FileName = Dir(ListFile & "*")
If FileName <> "" Then
Workbooks.Open (ListFile & FileName)
End If
End Sub
My Macro breaks at the FileName and I can't figure out why.
Is anyone able to help?
Thank you.