ItalianPlatinum
Well-known Member
- Joined
- Mar 23, 2017
- Messages
- 797
- Office Version
- 365
- 2019
- Platform
- Windows
Hello,
I have a VBA that will open a file based off of only certain criteria being met. the only ask or modification i'm looking for is how do I leverage the existing VBA to just close the file when its done.
Sub OpenCopy()
Dim sPath As String
Dim sPartial As String
Dim sFName As String
sPath = "C:\" ' <<<<< change accordingly
sPartial = "AAA_" & Year(Now) & IIf(Len(Month(Now)) = 1, "0" & Month(Now), Month(Now)) & IIf(Len(Day(Now)) = 1, "0" & Day(Now), Day(Now)) & "*.txt"
sFName = Dir(sPath & sPartial)
If Len(sFName) > 0 Then
Workbooks.OpenText sPath & sFName
Else
MsgBox "File not found.", vbExclamation
End If
End Sub
Thanks,
I have a VBA that will open a file based off of only certain criteria being met. the only ask or modification i'm looking for is how do I leverage the existing VBA to just close the file when its done.
Sub OpenCopy()
Dim sPath As String
Dim sPartial As String
Dim sFName As String
sPath = "C:\" ' <<<<< change accordingly
sPartial = "AAA_" & Year(Now) & IIf(Len(Month(Now)) = 1, "0" & Month(Now), Month(Now)) & IIf(Len(Day(Now)) = 1, "0" & Day(Now), Day(Now)) & "*.txt"
sFName = Dir(sPath & sPartial)
If Len(sFName) > 0 Then
Workbooks.OpenText sPath & sFName
Else
MsgBox "File not found.", vbExclamation
End If
End Sub
Thanks,