From: G Teachman on 29 Jan 2010 15:53 Hello, In my current project I have two variables that I initially set: MaxPages = Selection.Information(wdNumberOfPagesInDocument) CurPage = Selection.Information(wdActiveEndPageNumber) These are sent inside a Do Until loop that quits when CurPage = MaxPages. The first time I ran the macro it ran smoothly just like it was supposed to. The next time I ran the macro. Nothing happened. It occurred to me that maybe CurPage and MaxPages were still set and since they are equal the macro quits. This same behavior happened even after I got out of Word (2007) and back in again. What's going on and how can I make sure the variables are not set until the macro runs? Thanks, -- G Teachman Soil Scientist, USDA-NRCS
From: DaveLett on 29 Jan 2010 16:15 Hi, You can set those variables before the loop, as in the following example. MaxPages = Selection.Information(wdNumberOfPagesInDocument) CurPage = Selection.Information(wdActiveEndPageNumber) Do Until MaxPages = CurPage Selection.MoveDown unit:=wdParagraph, Count:=1 MaxPages = Selection.Information(wdNumberOfPagesInDocument) CurPage = Selection.Information(wdActiveEndPageNumber) Loop HTH, Dave "G Teachman" wrote: > Hello, > > In my current project I have two variables that I initially set: > > MaxPages = Selection.Information(wdNumberOfPagesInDocument) > CurPage = Selection.Information(wdActiveEndPageNumber) > > These are sent inside a Do Until loop that quits when CurPage = MaxPages. > > The first time I ran the macro it ran smoothly just like it was supposed to. > The next time I ran the macro. Nothing happened. It occurred to me that > maybe CurPage and MaxPages were still set and since they are equal the macro > quits. This same behavior happened even after I got out of Word (2007) and > back in again. > > What's going on and how can I make sure the variables are not set until the > macro runs? > > Thanks, > > -- > G Teachman > Soil Scientist, USDA-NRCS
|
Pages: 1 Prev: Word 2007 vs Word 2003 VBA autotext Next: Count the number of deleted manual page breaks |