Does anyone have a macro that will delete everything in a word document
EXCEPT items in a table?

Thanks,
Ryan---

--
RyGuy

Re: Delete Everything EXCEPT Items in a Table by Greg

Greg
Fri Oct 12 12:26:18 PDT 2007

Please ignore my idiotic previous post.


--
Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.


ryguy7272 wrote:
> Does anyone have a macro that will delete everything in a word
> document EXCEPT items in a table?
>
> Thanks,
> Ryan---



Re: Delete Everything EXCEPT Items in a Table by ryguy7272

ryguy7272
Fri Oct 12 12:33:01 PDT 2007

Got it!
Sub DelNonTables()
Dim myPara As Paragraph
For Each myPara In ActiveDocument.Paragraphs
If Not myPara.Range.Information(wdWithInTable) Then
myPara.Range.Delete
End If
Next

End Sub

--
RyGuy


"Greg Maxey" wrote:

> Please ignore my idiotic previous post.
>
>
> --
> Greg Maxey/Word MVP
> See:
> http://gregmaxey.mvps.org/word_tips.htm
> For some helpful tips using Word.
>
>
> ryguy7272 wrote:
> > Does anyone have a macro that will delete everything in a word
> > document EXCEPT items in a table?
> >
> > Thanks,
> > Ryan---
>
>
>

Re: Delete Everything EXCEPT Items in a Table by Greg

Greg
Fri Oct 12 12:31:12 PDT 2007

Ok. Again provided that each table is separated by at least one empty
paragraph (otherwise all tables will be joined as one big table) then:

Sub Test()
Dim oPar As Paragraph
For Each oPar In ActiveDocument.Range.Paragraphs
If Not oPar.Range.Information(wdWithInTable) And Len(oPar.Range.Text) > 1
Then
oPar.Range.Delete
End If
Next
End Sub


--
Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.


ryguy7272 wrote:
> Does anyone have a macro that will delete everything in a word
> document EXCEPT items in a table?
>
> Thanks,
> Ryan---



Re: Delete Everything EXCEPT Items in a Table by ryguy7272

ryguy7272
Fri Oct 12 12:44:01 PDT 2007

Very Cool!! I just found my code on the web, probably at the same time you
were posting yours. Thank you very much Greg!!

For those interested in a related link click here:
http://www.microsoft.com/office/community/en-us/default.mspx?dg=microsoft.public.word.vba.general&tid=0e7f60cb-8f40-4483-8c13-703952bd9123&lang=en&cr=US&p=1

Look for the part that starts with "GOT IT!!!"

These macros, together, saved me a HUGE chunk of time.

Thanks again Greg!
Regards,
Ryan--


--
RyGuy


"Greg Maxey" wrote:

> Ok. Again provided that each table is separated by at least one empty
> paragraph (otherwise all tables will be joined as one big table) then:
>
> Sub Test()
> Dim oPar As Paragraph
> For Each oPar In ActiveDocument.Range.Paragraphs
> If Not oPar.Range.Information(wdWithInTable) And Len(oPar.Range.Text) > 1
> Then
> oPar.Range.Delete
> End If
> Next
> End Sub
>
>
> --
> Greg Maxey/Word MVP
> See:
> http://gregmaxey.mvps.org/word_tips.htm
> For some helpful tips using Word.
>
>
> ryguy7272 wrote:
> > Does anyone have a macro that will delete everything in a word
> > document EXCEPT items in a table?
> >
> > Thanks,
> > Ryan---
>
>
>