Thanks for the link dlsmith36. I found that in my initial searching and did used it as a starting point. I appreciate the input.
Here is an update.
I set up a couple of extra for loops to iterate thru the subfolders and each file and knock it against the part number listing I have in the excel sheet. And it seemed to be working when I stepped thru it but when I played the code from the beginning I get an "Input past end of file" error 62 on line
strtext = objfile.ReadAll.
As I understand this error it means that excel thinks I am trying to read or assign something after an "end of file" character.
This tells me that excel can't read the file as it is not pure text. Since I have already wasted too much time on this thing anyways and no one else seems to know the answer either. I am going to go back to the tried and true method of beating my head against a wall for two days and rename the files manually (and yes I realize that if I just done it that way in the first place I would have been done already)
I am posting the last of my code, maybe someone will find it useful for something completely unrelated.
Sub FileLoop()
Dim myobject As Object
Dim mysource As Object
Dim myfile As Object
Dim irow As Integer
Dim mySourcePath As String
Dim myend As Integer
Const ForReading = 1
Const ForWriting = 2
Dim oldPNpath As String
Dim newPNpath As String
Dim oldPN As String
Dim newPN As String
Dim objfso As Object
Dim objfile As TextStream
Dim strtext As String
Dim strnewtext As String
Dim includesubfolders As Boolean
Dim mysubfolder As Folder
Dim myfilename As String
Dim newfilename As String
mySourcePath = "C:\Users\bhale\Desktop\Self Test Adapters"
Set myobject = New Scripting.FileSystemObject
Set mysource = myobject.GetFolder(mySourcePath)
'Set myfile = mysource.Files
myend = ActiveSheet.UsedRange.Rows.Count
Application.ScreenUpdating = False
'On Error Resume Next
For Each mysubfolder In mysource.SubFolders
Set mysource = myobject.GetFolder(mysubfolder.Path)
Set myfile = mysource.Files
For Each myfile In mysource.Files
Set objfile = myobject.OpenTextFile(myfile, ForReading, False, False)
strtext = objfile.ReadAll '-------------------------------------------------error was here
objfile.Close
For irow = 2 To myend
oldPN = Cells(irow, 2).Value
newPN = Cells(irow, 4).Value
strnewtext = Replace(strtext, oldPN, newPN)
myfilename = myfile.Name
newfilename = Replace(myfilename, oldPN, newPN, 1, -1, vbTextCompare)
Next
Set objfile = myobject.OpenTextFile(myfile.ParentFolder & "\" & newfilename, ForWriting, True)
objfile.Write strnewtext
objfile.Close
Kill myfile
Cells(irow, 5) = "check"
Next
Next
End Sub
Bookmarks