Live Chat & Podcast at 1:00PM Eastern on Sunday!
There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
Search
Business Applications
Tag Cloud
access acer asus bios bsod computer crash drive driver drivers error ethernet excel freeze gaming hard drive hardware hdmi internet laptop malware memory monitor motherboard network printer problem ram registry router security slow software sound toshiba trojan ubuntu 11.10 uninstall usb video virus vista wifi windows windows 7 windows 7 32 bit windows 7 64 bit windows xp wireless xbox
Search
Search for:
Tech Support Guy Forums > Software & Hardware > Business Applications >
Printing Page Breaks and Numbers

Reply  
Thread Tools
cristobal03's Avatar
Senior Member with 3,019 posts.
 
Join Date: Aug 2005
Experience: Advanced
03-Jan-2006, 01:52 PM #16
[bump 3]

Boy, this is old. Recently I got more involved in Word's object model, and I did in fact find a solution to this issue, using this tip found on the Microsoft Word MVP FAQ Site.

I don't know if the OP even uses TSG anymore, but here it is for future readers:

Code:
Option Explicit

Public Sub CollapseDoc()
  Dim doc      As Document
  Dim rng      As Range
  Dim strDoc   As String
  Dim strPage  As String
  Dim i        As Integer

  Const PAGE_BREAK_START  As String = "========================= Page "
  Const PAGE_BREAK_END    As String = " ========================="

  Set doc = Word.Application.ActiveDocument

  i = 1

  Do While i <= doc.Range.Information(wdNumberOfPagesInDocument)
    Set rng = doc.Range(0, 0)
    Set rng = rng.GoTo(what:=wdGoToPage, Name:=i)
    Set rng = rng.GoTo(what:=wdGoToBookmark, Name:="\page")

    With rng
      strPage = .Text
      strPage = Replace(strPage, vbNewLine, " ")
      strPage = strPage & vbNewLine & _
                PAGE_BREAK_START & i & _
                PAGE_BREAK_END & vbNewLine
      strDoc = strDoc & strPage
    End With
    i = i + 1
  Loop

  PostCollapsedDoc doc.Name, strDoc
End Sub

Private Sub PostCollapsedDoc(ByVal strName As String, _
                             ByVal strIn As String)
  Dim doc  As Document

  Set doc = Word.Documents.Add

  With doc.Range
    .Text = strIn
    With .Find
      .Forward = True
      .MatchWholeWord = True
      .Wrap = wdFindContinue
      .Execute Findtext:="^m", ReplaceWith:="", Replace:=wdReplaceAll
    End With
    .Paragraphs.SpaceBefore = 6
    With .Font
      .Name = "Tahoma"
      .Size = 8
    End With
  End With

  With Word.Application.Dialogs(wdDialogFileSaveAs)
    .Name = "Collapse_of_" & strName
    .Show
  End With
End Sub
This works best in a document that has no tables or other objects (like textboxes, images, or form fields). I wasn't sure what the OP meant by "dead space," so I basically trimmed hard carriage returns and manual page breaks.

Anyway, I came across that method to select a specific page today and thought I'd post a solution for this thread in case anybody needs it or the model on which it's based.

HTH

chris.

[edit]
Attached a couple of samples.
[/edit]
Attached Files
File Type: doc lorem ipsum sample.doc (57.0 KB, 108 views)
File Type: doc Collapse of lorem ipsum sample.doc (36.0 KB, 102 views)
Reply

THIS THREAD HAS EXPIRED.
Are you having the same problem? We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.

Search Tech Support Guy

Find the solution to your
computer problem!




Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
WELCOME TO TECH SUPPORT GUY! Are you looking for the solution to your computer problem? Join our site today to ask your question -- for free! Our site is run completely by volunteers who want to help you solve your computer problems. See our Welcome Guide to get started.
Thread Tools



Facebook Facebook Twitter Twitter TechGuy.tv TechGuy.tv Mobile TSG Mobile
You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 05:05 PM.
Copyright © 1996 - 2011 TechGuy, Inc. All rights reserved.

Powered by Cermak Technologies, Inc.