FileThere are 2 files.
- An excel file in which there are 4 columns consisting of 380 entries. The only column of my use is 2nd column.
- A notepad++ file in which a script is written.
I have to replace specific part of the script (one text value to be exact) with the value from excel data. For ease of understanding, say I have to replace "test_desc" from excel into the notepad++ script.
This is my code. I have opened the file, able to read each line, but I don't know how to access specific position of that line so that I can replace that value with "test_desc"
- Sub micro() //micro start
- Dim FSO As Scripting.FileSystemObject //declare FSO
- Set FSO = New Scripting.FileSystemObject //initialize FSO
- Dim myfile As Scripting.TextStream //declare myfile
- Set myfile = FSO.OpenTextFile("C:\Users\lenovo\Desktop\CTRY_CURY_STAGE.txt") //initialize myfile
- Dim var as String //declare string
- Dim count as Integer //declare count
- Do While Not myfile.AtEndOfLine //Read till end of file
- count = count + 1 //increment count to read what is the exact line at which I have to replace value
- var = myfile.ReadLine //read line one by one and store it in var
- If count = 9 Then //The line at which I have to replace the value
- SRC_COUNT_QUERY = 'SELECT COUNT(*) as cnt1 FROM DEV_EDW_STG_ECHANNELS_SRC.ICBR1B40'
- I have to replace ICBR1B40 with "test_descr" and ICBR1B40 is at 4 other instances but I can develop logic for it
- End If
- End Sub
I have been reading about doing it the other way using Open "File" for input as #1 , but the issue persists and I believe the logic is kind of same for each method
If I cannot automate it, I have to replace it for 380 files manually. Kindly help me resolve the issue
Thanks in anticipation