View Single Post
  #3   Report Post  
Posted to microsoft.public.word.newusers
Oggy Oggy is offline
external usenet poster
 
Posts: 6
Default select text, search, delete, in a macro, how?

macropod said the following on 8/11/2009 2:30 AM:

Word can probably do what you want with a wildcard-based Find/Replace
operation. For example:
Sub CleanUp()
With Selection
.HomeKey Unit:=wdStory
With .Find
.ClearFormatting
.Replacement.ClearFormatting
.Text = "(\div id)(*)(\\/div\)"
.Replacement.Text = "" ...


....

However, you haven't been clear about what distinguishes the string you
posted from similar strings you want to retain. The above macro will
delete all such strings in the document.


Thanks for the help! Thankfully, every section that I would want to
delete has a unique "id=" For instance, in the following..

div id="productdetails"
table border="0" cellspacing="0" cellpadding="0"
tr
td class="header" colspan="2"Product Details/td
/tr
tr valign="top"
td class="fieldlabel" nowrap="1"LoC /td
td class="fieldvalue"CPBBoxno.1797 .vol. 19/td
/tr
tr valign="top" ...
/table
/div
/td
td valign="top" width="50%"
div id="personaldetails"
table border="0" cellspacing="0" cellpadding="0"
tr
td class="header" colspan="2"Personal Details/td
/tr
tr valign="top"
td class="fieldlabel" nowrap="1"Links/td
td class="fieldvalue"
br/
br/
/td
/tr
/table
/div

...I want delete the table data between:

div id="productdetails" .. /div, and

div id="personaldetails" .. /div.


Therefore, I suppose I can replace your text above with:

..Text = "(\div id="productdetails")(*)(\\/div\)" ???


...and repeat for:

..Text = "(\div id="personaldetails")(*)(\\/div\)" ???