macros: find is unable to replace text in source: queryparams inhtml=true does not replace in html

M

MBParker

I'm doing VBA (macros) in the latest FrontPage 2003 with all updates.
However, is there still buggy stuff? Using a SearchInfo, find
replaces all the displayed text fine but seems to ignore in-html
(can't replace text in the source code).

I can do it fine manually via the Find & Replace window, but (as a
workaround) I don't know how to fill out the windows' fields via a VBA
macro.

And it looks like possibly others have also had this bug (macros can't
find & replace text in source):
http://groups.google.com/group/micr...&q=inhtml+queryparams&rnum=1#0914f35bb6b75ed2
(Automation of Find & Replace using VB) says "strQuery works but the
strRating query does not - at least not inside the code, it works as
a standalone normal FrontPage query."

Here's my code, almost straight from Microsoft's examples:

Sub QueryStringFindAndReplaceAll()
' 20070208+08+035539 by MBParker
' based on the subprocedure with same name in http://
msdn2.microsoft.com/en-us/library/aa218656(office.11).aspx
' but with the addition of inhtml=true ("Searches for the find string
in the HTML source code.")
'-- BUT the inhtml seems to have no effect; it only replaces in the
displayed HTML output
'Even the advanced varient (commented out here) does nothing more,
either.

' Dim objDocument As IHTMLTxtRange
' Set objDocument = ActiveDocument.body.createTextRange
' Dim objFound As IHTMLTxtRange
' Set objFound = ActiveDocument.body.createTextRange
Dim objSearch As SearchInfo
Set objSearch = Application.CreateSearchInfo
objSearch.QueryContents = "<?xml version=""1.0"" " & _
"encoding=""utf-8"" ?>" & _
"<fpquery version=""1.0"">" & _
"<queryparams inhtml=""true"" />" & _
"<find text=""20070208053013"" />" & _
"<replace text=""" & GUID() & """ />" & _
"</fpquery>"

'Simple version:
objSearch.Action = fpSearchReplaceAllText
ActiveDocument.Find objSearch

'Advanced version:
' objSearch.Action = fpSearchReplaceText
' Dim blnFound As Boolean
' Do
' blnFound = ActiveDocument.Find(objSearch, objDocument,
objFound)
' Loop While blnFound = True
End Sub

Any ideas? Thanks!

Mike B. Parker
â–º Now Designing www.CommuniDB.com ―“Your CommunityDatabaseâ€â„¢ (Web
2.0) -- and we could sure use some automated GUIDs!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top