Ask Question Forum:
C
O
M
P
U
T
E
R
2
8
- Underline
- Bold
- Italic
- Indent
- Step
- Bullet
- Quote
- Cut
- Copy
- Paste
- Table
- Spelling
- Find & Replace
- Undo
- Redo
- Link
- Attach
- Clear
- Code
Y-position of the mouse cursor
Attachment:===
Seach text and insert some text into html by VBA

1- Open example.html file in vba
2- Search the location of a text ,"<script text/Javascript>" in example.html by VBA
3- Insert other text such as follows and insert it right below the seach location
var g_iSh = 0;
if (window.location.search)
g_iSh = window.location.search.split(/=/)[1];
window.setInterval("refreshPage()", 10000); //refresh every 10 sec
4- save the file with insertion in html format by VBA
5- Done
I've just done the part of the search whether the text is existed or not in the htm file
but the function could "not" find out the l exact line numbe or location of the text for
preparing text insertion. ICould you provide me some function related that part and related to the my task producedure descibed above ? Please advise ?
Duncan
Sub searchtext()Dim workbookname As StringDim searchtext As Stringworkbookname = ActiveWorkbook.Path & "example.htm"searchtext = "<script language=""JavaScript"">"fnFindText workbookname, searchtextEnd SubFunction fnFindText(strFilePath, strSrTxt)Dim strFileRes As StringDim fsoDim aDim fDim boolStFnd strFileRes = "File Exists" If strFileRes = "File Exists" Then Const ForReading = 1 Set fso = CreateObject("Scripting.FileSystemObject") Set f = fso.OpenTextFile(strFilePath, ForReading, True) Do While f.AtEndOfStream <> True a = f.readline 'MsgBox a If InStr(a, strSrTxt) <> 0 Then boolStFnd = "True" fnFindText = "Text found" Exit Do End If Loop If boolStFnd <> "True" Then fnFindText = "Text not found" MsgBox "Text Not Found" Else MsgBox "Text Found" End If f.Close Else fnFindText = "File does not exists" End If End Function
1:2:3:4:5:6:7:8:9:10:11:12:13:14:15:16:17:18:19:20:21:22:23:24:25:26:27:28:29:30:31:32:33:34:35:36:37:38:39:40:41:42:43:
Thanks for your reply and the question is done after taking out server variable in
Poision's code.
Dear Poision and PrisonBroken,
Would you switch to other new thread and answer the new question at
http://www.experts-exchange.com/Programming/Languages/Visual_Basic/Q_26576299.html ?
Thanks for your reply and the question is done after taking out server variable in
Poision's code.
Dear Poision and PrisonBroken,
Would you switch to other new thread and answer the new question at
http://www.experts-exchange.com/Programming/Languages/Visual_Basic/Q_26576299.html ?
Thanks for your reply and the question is done after taking out server variable in
Poision's code.
Dear Poision and PrisonBroken,
Would you switch to other new thread and answer the new question at
http://www.experts-exchange.com/Programming/Languages/Visual_Basic/Q_26576299.html ?
Thanks for your reply and the question is done after taking out server variable in
Poision's code.
Dear Poision and PrisonBroken,
Would you switch to other new thread and answer the new question at
http://www.experts-exchange.com/Programming/Languages/Visual_Basic/Q_26576299.html ?
Thanks for your reply and the question is done after taking out server variable in
Poision's code.
Dear Poision and PrisonBroken,
Would you switch to other new thread and answer the new question at
http://www.experts-exchange.com/Programming/Languages/Visual_Basic/Q_26576299.html ?
Thanks for your reply and the question is done after taking out server variable in
Poision's code.
Dear Poision and PrisonBroken,
Would you switch to other new thread and answer the new question at
http://www.experts-exchange.com/Programming/Languages/Visual_Basic/Q_26576299.html ?
Thanks for your reply and the question is done after taking out server variable in
Poision's code.
Dear Poision and PrisonBroken,
Would you switch to other new thread and answer the new question at
http://www.experts-exchange.com/Programming/Languages/Visual_Basic/Q_26576299.html ?
Thanks for your reply and the question is done after taking out server variable in
Poision's code.
Dear Poision and PrisonBroken,
Would you switch to other new thread and answer the new question at
http://www.experts-exchange.com/Programming/Languages/Visual_Basic/Q_26576299.html ?
Thanks for your reply and the question is done after taking out server variable in
Poision's code.
Dear Poision and PrisonBroken,
Would you switch to other new thread and answer the new question at
http://www.experts-exchange.com/Programming/Languages/Visual_Basic/Q_26576299.html ?