Home |
Search |
Today's Posts |
#1
|
|||
|
|||
Repeat macro until end of document
I apologize if there is an easy answer for this - I have looked all over and
cannot find one anywhere. How do I get a macro to repeat until it reaches the end of the document, at which point it terminates? I have a document with a large number of similarly formatted tables. I am trying to perform a number of formatting changes with macros (e.g., resize columns, change borders, move columns). There are cases in which it ruins the table if the macro goes back to the beginning of the document and reapplies itself to tables it has already altered (e.g., moving a column a second time). I am working in Word 2000 and Windows 2000. Please let me know if you need more specific information than this to provide an answer. Thanks! |
#2
|
|||
|
|||
On Wed, 6 Jul 2005 17:30:02 -0700, Chris@PDX
wrote: I apologize if there is an easy answer for this - I have looked all over and cannot find one anywhere. How do I get a macro to repeat until it reaches the end of the document, at which point it terminates? I have a document with a large number of similarly formatted tables. I am trying to perform a number of formatting changes with macros (e.g., resize columns, change borders, move columns). There are cases in which it ruins the table if the macro goes back to the beginning of the document and reapplies itself to tables it has already altered (e.g., moving a column a second time). I am working in Word 2000 and Windows 2000. Please let me know if you need more specific information than this to provide an answer. Thanks! Hi Chris, The general answer is to edit the macro so that it contains a loop, which repeats the formatting steps for each table in the document. The loop actually uses that language: Dim MyTable As Table For Each MyTable In ActiveDocument.Tables ' do the formatting of MyTable Next MyTable The 'do the formatting' could consist of calls to macros that already exist, if they're written to be called that way (but macros that you record aren't written that way...). If you need more help than that, I think you should be asking in the Programming group (which is actually the newsgroup microsoft.public.word.vba.beginners). -- Regards, Jay Freedman Microsoft Word MVP FAQ: http://word.mvps.org |
Reply |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Table in a Form | Tables | |||
create a macro in a merge document field | Mailmerge | |||
How to assign a macro to a shape in a word document? | Microsoft Word Help | |||
Turning off Line Numbering Macro unformats my document! | Page Layout | |||
Document object in protected form | Tables |