Results 1 to 12 of 12
  1. #1
    New Lounger
    Join Date
    May 2002
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    FrontPage Search and Replace macro (FP 2000)

    I need to be able to replace all instances of <p align*** but only inside the table /table tags...Help!

  2. #2
    Super Moderator
    Join Date
    Dec 2000
    Location
    New York, NY
    Posts
    2,970
    Thanks
    3
    Thanked 29 Times in 27 Posts

    Re: FrontPage Search and Replace macro (FP 2000)

    Here's something similar that was done last year - any help?

    Gary

  3. #3
    New Lounger
    Join Date
    May 2002
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: FrontPage Search and Replace macro (FP 2000)

    I had seen this, unfortunatly, i need to only repalce certain code within tables.

  4. #4
    Gold Lounger
    Join Date
    Dec 2000
    Location
    New Hampshire, USA
    Posts
    3,386
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: FrontPage Search and Replace macro (FP 2000)

    I did something similar.

    You can write a macro that runs in FrontPage.
    Macro passes the HTML form of the doc to Word and you do the needed changes in Word, then pass the revised HTML back to Word.

    Could be that you could do all of this within FRontPage, without involving Word, but I've not taken the time to investigate.

  5. #5
    New Lounger
    Join Date
    May 2002
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: FrontPage Search and Replace macro (FP 2000)

    That's aprt of the problem is i'm trying to strip the codes Word2000 put into my tables.

  6. #6
    Gold Lounger
    Join Date
    Dec 2000
    Location
    New Hampshire, USA
    Posts
    3,386
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: FrontPage Search and Replace macro (FP 2000)

    Have you looked at article Q291325 in MSFT's KB?
    Does that do what you desire?

  7. #7
    New Lounger
    Join Date
    May 2002
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: FrontPage Search and Replace macro (FP 2000)

    I have, but unfortunatly that filter does not work very well at all.

  8. #8
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: FrontPage Search and Replace macro (FP 2000)

    Yes, it's truly lousy. I find it very frustrating and time-consuming to lighten the verbose code Word generates, but that's neither here nor there. The advantage of using Word automation to edit the source (as text, not as HTML converted back to Word), is the ability to define a range from your initial <TABLE> tag to your closing </TABLE> tag and run a Replace over that range. This is similar to interactively selection the table, running a Replace All, and then saying No when Word asks if you want to run it against the rest of the document.

    It's a lot of work, schlepping pages back and forth to Word. How many pages are we talking about?

    Long ago, I posted some code that uses the RegExp object in VBScript to do wildcard replaces (it was called WildReplace). If the

    tags are adjacent to the <td> tags, you might be able to write a wildcard replace that way without using Word, but if the

    tags are in arbitrary positions in the cells, it's probably too complicated.

    As soon as I find a free week to write a "real" Word-to-HTML filter or a filter for the filter, I'll let you know. Donations appreciated.

  9. #9
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: FrontPage Search and Replace macro (FP 2000)

    I just looked at the message linked in Gary's post, and I think you could add a step inside the loop to locate the table tags, define a range, and then run a replace against that. If there are no nested tables, that's the ideal case, but if all of your tables are at least nested to the same depth, that's almost as good. Something like this:

    <pre>Dim rngTemp As Range
    Selection.HomeKey wdStory, wdMove
    Do
    With Selection.Find
    .ClearFormatting
    ' Note, wildcard searches are case sensitive; your TAG style may vary
    .Text = "<table*</table>"
    .Replacement.Text = ""
    .Forward = True
    .Wrap = wdFindStop
    .Format = False
    .MatchCase = False
    .MatchWholeWord = False
    .MatchAllWordForms = False
    .MatchSoundsLike = False
    .MatchWildcards = True
    If .Execute = False Then
    Exit Do
    End If
    ' At this point, the first table is selected
    Set rngTemp = Selection.Range
    ' Run a replace within rngTemp for

    tags
    ' [YOUR CODE HERE]
    ' Collapse the selection to its end and loop
    ' to see if there are more tables
    Selection.Collapse wdCollapseEnd
    End With
    Loop</pre>

    I haven't had time to test this out, but in theory it seems as though it ought to limit you to the tables. Hope this helps.

  10. #10
    New Lounger
    Join Date
    May 2002
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: FrontPage Search and Replace macro (FP 2000)

    Sometimes, these docuements can be up to 300 pages!

  11. #11
    New Lounger
    Join Date
    May 2002
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: FrontPage Search and Replace macro (FP 2000)

    Good idea, i put both together and now have the code below.....it works well, however, how can i make it loop so that it will get all the other tables, right now it stops after the first table...

    Dim strFolder As String
    Dim strFind As String, strReplace As String
    Dim rngTemp As Range

    strFind = InputBox("Enter the string to look for.", "Find")
    strReplace = InputBox("Enter the string to replace.", "Replace")

    With Dialogs(wdDialogCopyFile)
    If .Display = -1 Then strFolder = .Directory
    End With

    With Application.FileSearch
    .FileName = ".htm"
    .LookIn = strFolder
    .Execute
    .SearchSubFolders = False
    For i = 1 To .FoundFiles.Count
    WordBasic.disableautomacros
    Documents.Open .FoundFiles(i), Format:=wdOpenFormatText
    Do
    Selection.HomeKey wdStory, wdMoveDo
    With Selection.Find
    .ClearFormatting
    .Text = "<table*</table>"
    .Replacement.Text = ""
    .Forward = True
    .Wrap = wdFindStop
    .Format = False
    .MatchCase = False
    .MatchWholeWord = False
    .MatchAllWordForms = False
    .MatchSoundsLike = False
    .MatchWildcards = True
    If .Execute = False Then
    Exit Do
    End If ' At this point, the first table is selected
    Set rngTemp = Selection.Range


    Selection.Find.ClearFormatting
    With Selection.Find
    .MatchWildcards = False
    .Forward = True
    .Wrap = wdFindStop
    .Text = strFind
    .Replacement.Text = strReplace
    .Execute Replace:=wdReplaceAll
    End With

    Selection.Collapse wdCollapse
    End
    End With
    Loop

    ActiveDocument.Close wdSaveChanges
    Next i
    End With

  12. #12
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: FrontPage Search and Replace macro (FP 2000)

    I don't have time to test this right now, but... first, rejoin the word "End" to the end of the previous line so it reads:

    Selection.Collapse wdCollapseEnd

    I don't know what kind of mischief that End might do sitting there...

    I envisioned that the inner replace would use the rngTemp.Find object, rather than the Selection.Find object, so try that next.

    If that doesn't work, before the replace code, try assigning a bookmark to the selection of the entire table, and then after the replace, re-select that bookmark and collapse the selection past to its end.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •