Pramodpandit123
New Member
- Joined
- Apr 18, 2020
- Messages
- 30
- Office Version
- 2016
- Platform
- Windows
Let me give you an example :
Image=Image1
Image=Image2
Image=Image3
TextImage=Image1
CSVImage=Image2
StringImage=Image2
I have a text file containing these words. How can i delete lines from this text file which contains "Image=" in its line i.e. Line 1st,2nd and 3rd should be deleted but Line 5th,6th and 7th should be as it is. How can i achieve it ? I am not proficient on VBA but i tried to use "Replace" on following code that i took reference from internet.
Image=Image1
Image=Image2
Image=Image3
TextImage=Image1
CSVImage=Image2
StringImage=Image2
I have a text file containing these words. How can i delete lines from this text file which contains "Image=" in its line i.e. Line 1st,2nd and 3rd should be deleted but Line 5th,6th and 7th should be as it is. How can i achieve it ? I am not proficient on VBA but i tried to use "Replace" on following code that i took reference from internet.
VBA Code:
Dim strFileName As String
Dim sBuf As String
Dim sTemp As String
Dim iFileNum As Integer
Dim sFileName As String
sFileName = "C:\Users\Epic\Desktop\PROJECT\PROJECT.txt"
returnvalue = Shell("notepad.exe " & sFileName, vbNormalFocus)
iFileNum = FreeFile
Open sFileName For Input As iFileNum
Do Until EOF(iFileNum)
Line Input #iFileNum, sBuf
sTemp = sTemp & sBuf & vbCrLf
Loop
Close iFileNum
sTemp = [B]Replace(sTemp, "[I]Image=[/I]", "")[/B]