Hi guys,
these may be a really simple problem but i can't find the solution by just
looking at VBA help file so i was wondering if anyone can help me with this:
Selection.GoTo What:=wdGoToPage, Which:=wdGoToNext, Count:=1, Name:=""
Selection.EndKey Unit:=wdLine, Extend:=wdExtend
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.GoTo What:=wdGoToPage, Which:=wdGoToNext, Count:=1, Name:=""
Selection.EndKey Unit:=wdLine, Extend:=wdExtend
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.GoTo What:=wdGoToPage, Which:=wdGoToNext, Count:=1, Name:=""
Selection.EndKey Unit:=wdLine, Extend:=wdExtend
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.GoTo What:=wdGoToPage, Which:=wdGoToNext, Count:=1, Name:=""
Selection.EndKey Unit:=wdLine, Extend:=wdExtend
Selection.Delete Unit:=wdCharacter, Count:=1
what i'm trying to do is make word go to the next page and delete the first
line and repeat the process till it reaches the last page...my problem is if
i use the command above it will keep on deleting lines even if it had already
reached the last page which in turn could end up deleting the entire last
page...im stuck...any help is greatly appreciated.
Thanks,
Gau
Cindy M -WordMVP- - 05 Aug 2006 10:17 GMT
Hi Gaubahn,
I think what you need to do is put this in a loop of some kind. You could
either get the number of pages, then loop exactly the number of times. Or
perform a check whether the current page is the last page. Not knowing the
document, it's difficult to make a suggestion. May one assume that you have a
manual page break between each page?
> these may be a really simple problem but i can't find the solution by just
> looking at VBA help file so i was wondering if anyone can help me with this:
[quoted text clipped - 17 lines]
> reached the last page which in turn could end up deleting the entire last
> page...im stuck...any help is greatly appreciated.
Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister
http://www.word.mvps.org
This reply is posted in the Newsgroup; please post any follow question or reply
in the newsgroup and not by e-mail :-)
gaubahn - 07 Aug 2006 08:20 GMT
Hi Cindy,
Yes, i do have manual page breaks between each page. Also, I'm not familiar
with how looping is done, and also not all documents have the same number of
pages. But I did manage to find a work around by making the macro insert an
additional pagebreak at the end of the document. But if you can teach me how
to do the looping with varying number of pages I'd greatly appreciate it.
Tnhanks,
Gau
>Hi Gaubahn,
>
[quoted text clipped - 17 lines]
>This reply is posted in the Newsgroup; please post any follow question or reply
>in the newsgroup and not by e-mail :-)
Cindy M. - 07 Aug 2006 14:36 GMT
Hi Gaubahn,
> Yes, i do have manual page breaks between each page. Also, I'm not familiar
> with how looping is done, and also not all documents have the same number of
> pages. But I did manage to find a work around by making the macro insert an
> additional pagebreak at the end of the document. But if you can teach me how
> to do the looping with varying number of pages I'd greatly appreciate it.
>
I'd approach it something like this
Dim pageCount as Long
Dim counter as long
pageCount = ActiveDocument.ComputeStatistics(wdStatisticPages)
Selection.HomeKey wdStory 'go to start of doc
For counter = 2 to pageCount
Selection.EndKey Unit:=wdLine, Extend:=wdExtend
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.GoTo What:=wdGoToPage, Which:=wdGoToNext, Count:=1, Name:=""
Next
> >I think what you need to do is put this in a loop of some kind. You could
> >either get the number of pages, then loop exactly the number of times. Or
[quoted text clipped - 7 lines]
> >> reached the last page which in turn could end up deleting the entire last
> >> page...im stuck...any help is greatly appreciated.
Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
http://www.word.mvps.org
This reply is posted in the Newsgroup; please post any follow question or reply in
the newsgroup and not by e-mail :-)