| MBParker@Alum.MIT.Edu 2007-02-08, 6:16 pm |
| 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...ent/browse_thr=
ead/thread/37651078df52d65f/0914f35bb6b75ed2?lnk=3Dst&q=3Dinhtml+queryparam=
s&rnum=3D1#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=3Dtrue ("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 =3D ActiveDocument.body.createTextRange
' Dim objFound As IHTMLTxtRange
' Set objFound =3D ActiveDocument.body.createTextRange
Dim objSearch As SearchInfo
Set objSearch =3D Application.CreateSearchInfo
objSearch.QueryContents =3D "<?xml version=3D""1.0"" " & _
"encoding=3D""utf-8"" ?>" & _
"<fpquery version=3D""1.0"">" & _
"<queryparams inhtml=3D""true"" />" & _
"<find text=3D""20070208053013"" />" & _
"<replace text=3D""" & GUID() & """ />" & _
"</fpquery>"
'Simple version:
objSearch.Action =3D fpSearchReplaceAllText
ActiveDocument.Find objSearch
'Advanced version:
' objSearch.Action =3D fpSearchReplaceText
' Dim blnFound As Boolean
' Do
' blnFound =3D ActiveDocument.Find(objSearch, objDocument,
objFound)
' Loop While blnFound =3D True
End Sub
Any ideas? Thanks!
Mike B. Parker
=E2=96=BA Now Designing www.CommuniDB.com =E2=80=95=E2=80=9CYour Community=
Database=E2=80=9D=E2=84=A2 (Web
2=2E0) -- and we could sure use some automated GUIDs!
|