
MS Word VBA: Looping through opened Windows
Yah, Astrid, just a typo indeed:
Window(i).Activate
IS the same as
Window(i).Activate
BUT will not work like
Windows(i).Activate
- Robert. ;-)
Quote:
> Hi Bill,
> It's just a typo, use:
> Window(i).Activate
> instead of
> Window(i).Activate
> Hope this helps,
> regards,
> Astrid (Microsoft Word MVP)
> For direct access to all Microsoft newsgroups:
> > I get a "sub or function not defined" error when compiling the
> > following WIN95 MS Word 97 macro code:
> > Sub Macro2()
> > '
> > ' Macro2 Macro
> > ' Macro recorded 05/17/00 by BKNOWLTO
> > '
> > Dim i As Integer
> > For i = 1 To 23
> > Window(i).Activate
> > Selection.MoveDown Unit:=wdLine, Count:=2
> > Selection.MoveDown Unit:=wdLine, Count:=3, Extend:=wdExtend
> > Selection.Copy
> > Windows(24).Activate
> > Selection.Paste
> > Next
> > End Sub
> > Apparently one cannot address a Window using *variable* subscripts like
> > Window(i). Hard coding for a particular instance of i, say 2 (and the
> > fixed target Windows(24)) cause no problems. How can I program the
> > macro to loop through windows 1 through 23?
> > Any thoughts would be much appreciated.
> > A VBA newbie,
> > Bill