I have a notepad containing tags.
My requirement is to change the data as below:
My input file will have 1000+ lines with the similar data to be replaced.
Actual:
<a xlink:href="javascript:alert('XGMC021D');" xlink:title="XGMC021D">
<ellipse fill="none" stroke="black" cx="1548" cy="-898" rx="59.0322" ry="18"/>
Expected:
< elipse id="XGMC021D" style="fill:none;stroke:black; " cx="1548" cy="-898" rx="59.0322" ry="18"/>
1. In the first line, I'm removing entire data till title and replacing with < elipse id
2. First line and second line should be combined and in the second line, from < ellipse fill , it should replace with style....black;
I have code written for the first action, but for the second, I dont have.
Code in NOTEPAD:
Const ForReading = 1
Const ForWriting = 2
Const ForAppending = 8
Set objShell = CreateObject("WScript.Shell")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objRegEx = CreateObject("VBScript.RegExp")
Set objFile = objFSO.OpenTextFile("C:\Users\XXXXX\Desktop\Sample file.svg",ForReading) 'File you want Parsed
Set outputfile = objFSO.CreateTextFile("Parsed.txt", True) 'Output File
objRegEx.IgnoreCase = True
objRegEx.MultiLine = True
objRegEx.Global = True
objRegEx.Pattern = "a xlink:href.*title"
Results = ""
Do Until objFile.AtEndOfStream
line = objFile.ReadLine
outputfile.WriteLine(objRegEx.Replace(line, "elipse id"))
Loop
objFile.Close
WScript.Echo "Done"
Can anyone pls help me in getting the above done from excel macro?
Also while trying to execute the same code in Excel macro, outfile is not getting generated.
My requirement is to change the data as below:
My input file will have 1000+ lines with the similar data to be replaced.
Actual:
<a xlink:href="javascript:alert('XGMC021D');" xlink:title="XGMC021D">
<ellipse fill="none" stroke="black" cx="1548" cy="-898" rx="59.0322" ry="18"/>
Expected:
< elipse id="XGMC021D" style="fill:none;stroke:black; " cx="1548" cy="-898" rx="59.0322" ry="18"/>
1. In the first line, I'm removing entire data till title and replacing with < elipse id
2. First line and second line should be combined and in the second line, from < ellipse fill , it should replace with style....black;
I have code written for the first action, but for the second, I dont have.
Code in NOTEPAD:
Const ForReading = 1
Const ForWriting = 2
Const ForAppending = 8
Set objShell = CreateObject("WScript.Shell")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objRegEx = CreateObject("VBScript.RegExp")
Set objFile = objFSO.OpenTextFile("C:\Users\XXXXX\Desktop\Sample file.svg",ForReading) 'File you want Parsed
Set outputfile = objFSO.CreateTextFile("Parsed.txt", True) 'Output File
objRegEx.IgnoreCase = True
objRegEx.MultiLine = True
objRegEx.Global = True
objRegEx.Pattern = "a xlink:href.*title"
Results = ""
Do Until objFile.AtEndOfStream
line = objFile.ReadLine
outputfile.WriteLine(objRegEx.Replace(line, "elipse id"))
Loop
objFile.Close
WScript.Echo "Done"
Can anyone pls help me in getting the above done from excel macro?
Also while trying to execute the same code in Excel macro, outfile is not getting generated.
Last edited: