![]() |
#1
|
|||
|
|||
![]()
Hi all
I want to loop true all opened word documents but my code stays on the first selected file. It also only just loops 2 times even if I have more files opened. Dim wd As Range For Each wd In ActiveDocument.Words wd.Select MsgBox (wd.Document.Name) 'Do stuff next wd |
#2
|
||||
|
||||
![]()
That code is only looping Words, not documents. Try nesting your loops like the following aircode
Code:
Dim aDoc as Document, wd as Range For each aDoc in Application.Documents For each wd in aDoc.Words 'do stuff Next wd Next aDoc
__________________
Andrew Lockton Chrysalis Design, Melbourne Australia |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
VB for Word - Need macro to loop each line in a document | NDeane | Word VBA | 5 | 12-22-2015 08:12 PM |
![]() |
spiderman1369 | Word VBA | 2 | 10-15-2014 08:30 AM |
![]() |
ilcaa72 | Word VBA | 4 | 02-13-2014 11:48 AM |
![]() |
kilburfi | Word VBA | 2 | 07-12-2013 01:26 AM |
![]() |
Yamaha Rider | Word VBA | 2 | 02-07-2012 05:33 PM |