View Single Post
  #6   Report Post  
Posted to microsoft.public.word.docmanagement
eb eb is offline
external usenet poster
 
Posts: 24
Default Delete Word table with macro

Lene,

Thanks for the help, I really appreciate it. I have one more question, I'm
trying to remove two words from my document. One is the word "Telephone" and
the other is "facsimile." I have been trying to add this to the code you
provided but I keep getting errors. Any ideas how I can remove those two
words?

thanks,

"Lene Fredborg" wrote:

The macro below will delete all tables in the active document:

Sub DeleteAllTables()

Dim oTable As Table

For Each oTable In ActiveDocument.Tables
oTable.Delete
Next oTable

End Sub

Note that your macro could be adjusted to delete all tables too (in the
current version, it will delete only the last table).

How to delete the logo depends on how and where it is inserted:
Is it €śIn line with text€ť or floating?
Is it in the main body of the document or, e.g., in the header?
Are there other graphics (drawings, pictures, etc.) in the document?

If the logo is the only graphic, inserted in the main body of the document
and "In line with text" (i.e. in the text layer of the document), the
following code line could be used to remove it:

ActiveDocument.InlineShapes(1).delete

If the wrapping style is any other than €śIn line with text€ť (i.e. the logo
is in the drawings layer of the document), you need to use €śShapes€ť instead
of €śInlineShapes€ť:

ActiveDocument.Shapes(1).delete

--
Regards
Lene Fredborg
DocTools - Denmark
www.thedoctools.com
Document automation - add-ins, macros and templates for Microsoft Word


"EB" wrote:

Ok, I'm not sure how to write that macro since I'm new to macros. I've been
recording and then trying to edit the code. I found this one that is supposed
to delete the last table, but I cant figure out how to edit it so that it
deletes all of the tables plus the logo. this is the code:

Dim nTables As Integer
nTables = ActiveDocument.Tables.Count
ActiveDocument.Tables(nTables).Delete

"RichN" wrote:

One way - and this assumes there is some text after the 2 tables and the logo
- would be to write the macro so that you use "Find" to go to the spot before
the 1st table, then use "Find" again to go to the spot after the 2nd table
and logo.

"EB" wrote:

Hello,

I have a macro that should be deleting 2 tables in my document plus a logo.
I got it to delete one table, but i cant seem to get it to delete both tables
and the logo. The code looks like this: ActiveDocument.Tables(1).Delete

what is the proper code to get the macro to delete all tables in the
document plus the logo?

any help is appreciated.