Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Delete Word table with macro
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. |
#2
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Delete Word table with macro
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. |
#3
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Delete Word table with macro
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. |
#4
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Delete Word table with macro
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. |
#5
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Delete Word table with macro
Lane, The picture right now is set to In-line with text, however, I have
changed it a few times and I can still change it to accomodate the macro. I will let you know how things worked out. 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. |
#6
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
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. |
#7
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Delete Word table with macro
Before I try to suggest a solution I would like to know a little mo
Are the two words found more than once - and in that case, do you want all occurrences to be removed? or Are the two words found only once - maybe in a specific place in the document? -- Regards Lene Fredborg DocTools - Denmark www.thedoctools.com Document automation - add-ins, macros and templates for Microsoft Word "EB" wrote: 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. |
Reply |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Word should catalog misspelled words to study. | Microsoft Word Help | |||
How to put graphics on envelopes? | Microsoft Word Help | |||
Change paper size; Word changes to invalid margins | New Users | |||
How do I create Word macro that will run properly using copy/past. | Microsoft Word Help | |||
Table in a Form | Tables |