Hello, I am trying to create a macro to pull a .txt file from my computer into excel, line for line. I generated the code below yesterday and it was running great without any problems. Today I opened the code to keep working on other steps to the program and it could no longer find the file on my drive. Every time I run the program, it gives me an error message "run-time error '75': Path/File access error" and stops at the "Open MyFile For Input As #1" command line. Below is my Code. Any suggestions would be great, thank you.
Sub Part_selection()
Dim MyFolder As String
Dim MyFile As String
MyFolder = "C:\Users\William.Rudan\Documents\1 Projects\Form Bending\5130 Program Files\Test PressBrake NC codes" & "\"
MyFile = Dir(MyFolder & Range("B2") & ".txt")
Worksheets("Temp").Select
Open MyFile For Input As #1
X = 0
Do While Not EOF(1)
Line Input #1, TXT
Cells(1, 1).Offset(X, 0) = TXT
X = X + 1
Loop
Close #1
Worksheets("Operation_Sheet").Select
Cells(2, 6).Interior.Color = RGB(100, 250, 100)
End Sub
Sub Part_selection()
Dim MyFolder As String
Dim MyFile As String
MyFolder = "C:\Users\William.Rudan\Documents\1 Projects\Form Bending\5130 Program Files\Test PressBrake NC codes" & "\"
MyFile = Dir(MyFolder & Range("B2") & ".txt")
Worksheets("Temp").Select
Open MyFile For Input As #1
X = 0
Do While Not EOF(1)
Line Input #1, TXT
Cells(1, 1).Offset(X, 0) = TXT
X = X + 1
Loop
Close #1
Worksheets("Operation_Sheet").Select
Cells(2, 6).Interior.Color = RGB(100, 250, 100)
End Sub