Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / March 2005

Tip: Looking for answers? Try searching our database.

macro deleting pages

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Julia - 03 Mar 2005 01:11 GMT
Hi - this macro should find "Invoice=" and then select from the previous page
break to the following page break and delete.  It's deleting multiple pages.  
Any ideas why?  I really appreciate the help:

Sub BillAdd1()
'

With Selection
  .WholeStory
  .ExtendMode = False
  .Collapse
End With

With Selection.Find

   .Text = "invoice="
       .Replacement.Text = ""
       .Forward = True
       .Wrap = wdFindStop
       
       .Format = False
       .MatchCase = False
       .MatchWholeWord = False
       .MatchWildcards = False
       .MatchSoundsLike = False
       .MatchAllWordForms = False


  While .Execute
'   Selection.Find.Execute
   Selection.HomeKey unit:=wdLine
   With Selection.Find
       .Text = "^m"
       .Replacement.Text = ""
       .Forward = False
       .Wrap = wdFindStop
       '.Wrap = wdFindAsk
       
   End With
   Selection.Find.Execute
   Selection.MoveRight unit:=wdCharacter, Count:=1
   Selection.Extend
   Selection.Find.ClearFormatting
   With Selection.Find
       .Text = "^m"
       .Replacement.Text = ""
       .Forward = True
       .Wrap = wdFindAsk

   End With
   Selection.Find.Execute
   Selection.Delete unit:=wdCharacter, Count:=1
   Selection.MoveDown unit:=wdLine
  Wend

  End With
   
End Sub
Doug Robbins - 03 Mar 2005 02:10 GMT
Once you find the "Invoice=", delete the range of the built-in bookmark
"\page"

Selection.Bookmarks("\page").Range.Delete

Signature

Please respond to the Newsgroup for the benefit of others who may be
interested.   Questions sent directly to me will only be answered on a paid
consulting basis.

Hope this helps,
Doug Robbins - Word MVP

> Hi - this macro should find "Invoice=" and then select from the previous
> page
[quoted text clipped - 55 lines]
>
> End Sub
Julia - 03 Mar 2005 02:47 GMT
Thanks Doug.  I don't know enough to know where to place that line of code
you gave me, but I'm trying.  thanks

> Hi - this macro should find "Invoice=" and then select from the previous page
> break to the following page break and delete.  It's deleting multiple pages.  
[quoted text clipped - 54 lines]
>    
> End Sub
Julia - 03 Mar 2005 02:55 GMT
Doug - I figured it out, thank you so much!

> Hi - this macro should find "Invoice=" and then select from the previous page
> break to the following page break and delete.  It's deleting multiple pages.  
[quoted text clipped - 54 lines]
>    
> End Sub
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.