Results 1 to 4 of 4
  1. #1
    3 Star Lounger
    Join Date
    Aug 2002
    Location
    Denmark
    Posts
    347
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Deleting sections in Word doc. (Win XP/ O2003)

    Hi,

    Looking for a quick solution to a specific problem.

    Got a large template "Report" with numerous sections defined. In each section specific elements are available.
    Now I need to make a "light" and an "ultra-light" version - each reducing the number of specific elements.

    Got a commandbar with each as an element eg. one is "Report", one is "Report light", last is "Report ultra-light"
    When running menupoints I target three different subs.

    Each sub creates the doc based on the same template - subsequently before finishing removing the overhead sections.

    Imagine code dould look like

    Set ThisDoc = Documents.Add(strTplFull)
    ......code make modifications in between

    With thisdoc
    intSections = .sections.count -2

    'Here I need to delete sections 2 to intsections
    '?????????????
    end with
    Bests,
    RD


    PS: Wish there were a knob on the TV to turn up the intelligence. There's a knob called "brightness," but that doesn't work

  2. Subscribe to our Windows Secrets Newsletter - It's Free!

    Get our unique weekly Newsletter with tips and techniques, how to's and critical updates on Windows 7, Windows 8, Windows XP, Firefox, Internet Explorer, Google, etc. Join our 480,000 subscribers!

    Excel 2013: The Missing Manual

    + Get this BONUS — free!

    Get the most of Excel! Learn about new features, basics of creating a new spreadsheet and using the infamous Ribbon in the first chapter of Excel 2013: The Missing Manual - Subscribe and download Chapter 1 for free!

  3. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 16 Times in 16 Posts

    Re: Deleting sections in Word doc. (Win XP/ O2003)

    Try

    Dim i As Integer
    For i = intSectionsTo 2 Step -1
    .Sections(i).Range.Delete
    Next i

    Warning: deleting sections can have unexpected side effects if the sections have different page setups or different headers and footers.

  4. #3
    3 Star Lounger
    Join Date
    Aug 2002
    Location
    Denmark
    Posts
    347
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Deleting sections in Word doc. (Win XP/ O2003)

    Hi Hans,

    In you I trust! / ;o)

    I'm painfully aware of the delete aspect, but as you also indicate about margins etc. this shouldn't be a problem as long as all sections are identical in that respect - and they are... - was intentionally created that way (he-he)

    was the .range. that I was missing. Btw. how come it's needed in this case? seems like slight overhead... having both section and range I mean...

    Anyway - big thanx
    Bests,
    RD


    PS: Wish there were a knob on the TV to turn up the intelligence. There's a knob called "brightness," but that doesn't work

  5. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 16 Times in 16 Posts

    Re: Deleting sections in Word doc. (Win XP/ O2003)

    Microsoft could have implemented a Delete method for sections, but they didn't, so you have to delete the range associated with the section. I don't think this will make a difference in performance.

Posting Permissions

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