Results 1 to 3 of 3

Thread: To delete a Word Page

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2003
    Posts
    2

    Unhappy To delete a Word Page

    Dear all,

    Do any of your know how to delete a page form a word document using VB Code.
    Thank alot


    EricLun

  2. #2
    Don't Panic! Ecniv's Avatar
    Join Date
    Nov 2000
    Location
    Amsterdam...
    Posts
    5,343
    Possibly.

    You could try looking at recording what happens when you manually delete the page then translating to code. Pls note that its best not to cut n paste as the selection object is weird when automating. I found out this the hard way.


    Vince

    BOFH Now, BOFH Past, Information on duplicates

    Feeling like a fly on the inside of a closed window (Thunk!)
    If I post a lot, it is because I am bored at work! ;D Or stuck...
    * Anything I post can be only my opinion. Advice etc is up to you to persue...

  3. #3
    Fanatic Member WorkHorse's Avatar
    Join Date
    Jul 2002
    Location
    Where you live.
    Posts
    591
    MS Word doesn't really think in terms of pages. This is should work to delete the current page.

    VB Code:
    1. Dim rngEnd As Range
    2. Dim rngStart As Range
    3.  
    4. Application.Browser.Target = wdBrowsePage
    5. Application.Browser.Next
    6. Set rngEnd = Selection.Range
    7. Application.Browser.Previous
    8. Set rngStart = Selection.Range
    9.  
    10. ActiveDocument.Range(rngStart.Start, rngEnd.End).Text = ""

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width