• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

excel vba replace text in jsfile at specific conditions

yogeshvasu

New Member
Hello Everyone,

i am having js files in a folder , i am reading js file as text stream(notepad) using excel vba and i am replacing text in notepad by finding out the word in excel file first column and replacing same row second column data .
for example category is a text in notepad if i am searching in first column and replacing text in notepad in second column. it should not replace what ever the text searches in excel , it should replace in notepad with text starting with " some text /"
this is my js file content
//******************************************//***** Category Data for eWD Category *****//******************************************function CateList_CircuitData(){//******************************************//***** Circuit Section Part *****//******************************************


CategoryArr1["A"]="A";
CategoryArr1["B"]="B";
CategoryArr1["D"]="D";
CategoryArr1["F"]="F";
CategoryArr1["H"]="H";
CategoryArr1["I"]="I";
CategoryArr1["J"]="J";
CategoryArr1["K"]="K";
CategoryArr1["L"]="L";
CategoryArr1["M"]="M";
CategoryArr1["N"]="N";
CategoryArr1["O"]="O";

CategoryArr2["A"]="
title\" class="pagetitle\">SUB-SECTION
"+"
datalist\" name="**GI GENERAL INFORMATION**\" ***********="List_CateListMouseOver(this,\'Circuit Diagram\',\'A\',\'GI GENERAL INFORMATION\',2)">"+"datalisttbl\">"+""+""+""+""+"
datalisttd1\">GI GENERAL INFORMATIONdatalisttd2\">[img name="\" src="../../common/image/other/tri.gif\">
"+"
";in this js file i have to replace text starts with " some text " other text should not be replaced
this is my code
str_Path = Arrange_path1Set fso = CreateObject("Scripting.FileSystemObject")ForEach fil In fso.GetFolder(str_Path).Files
If fil.Type ="JS File"ThenSet txt = fil.OpenAsTextStream(1)


str_change = txt.ReadALL


Lines = DataBook.ActiveSheet.Range("A65536").End(xlUp).RowFor i =1To Lines
wer = DataBook.ActiveSheet.Cells(i,1).Value
wer2 = DataBook.ActiveSheet.Cells(i,2).Value

str_change = Replace(str_change, wer, wer2, vbTextCompare)Next iWith fil.OpenAsTextStream(2).Write str_change.CloseEndWithEndIfNext filEndSub
 
Hi !

As explained you must use code tags !

Unclear : is there any need, any question ?

If the answer is yes, so with a crytal clear and complete explanation
you must also join Excel workbook, source text file and
expected result text file according from source text file & workbook …
 
Back
Top