Reply
 
Thread Tools Display Modes
  #1   Report Post  
Chris@PDX
 
Posts: n/a
Default 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   Report Post  
Jay Freedman
 
Posts: n/a
Default

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

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Table in a Form HiDbLevel Tables 12 February 27th 06 12:59 PM
create a macro in a merge document field wilddove Mailmerge 3 June 15th 05 11:14 AM
How to assign a macro to a shape in a word document? Frank Microsoft Word Help 1 February 25th 05 01:45 AM
Turning off Line Numbering Macro unformats my document! Victoria Page Layout 1 January 21st 05 12:34 AM
Document object in protected form Bruce Tables 2 December 6th 04 07:09 PM


All times are GMT +1. The time now is 05:17 AM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"