Good afternoon,
I am trying to run a script that will open a .txt file where only part of the file name is known. My code is below. The Range below, NHCUopenFilePath refers to the file location C:\TempPath\NHCUPaymentfile06272018*.txt The * denotes the place where 10 random digits will appear on the .txt file that needs to be opened. When I run this code below, I'm receiving a runtime error 1004, unable to find file path.
Sub NHCUOpenImport()
Application.ScreenUpdating = False
Dim wbI As Workbook, wbO As Workbook
Dim wsI As Worksheet
Set wbI = ThisWorkbook
Set wsI = wbI.Sheets("Data")
Set wbO = Workbooks.Open(Range("NHCUopenFilePath"))
wbO.Sheets(1).Cells.Copy wsI.Cells
wbO.Close SaveChanges:=False
Set wbI = Nothing
Set wsI = Nothing
Set wbO = Nothing
Application.ScreenUpdating = True
End Sub
Bookmarks