Mourning the loss of our friend, WhitPhil.
There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
Search
 
Business Applications
Tag Cloud
access audio black screen blue screen boot bsod connection crash desktop driver drivers dvd email error excel firefox hard drive hardware hijackthis internet keyboard laptop malware monitor motherboard network networking outlook problem processor ram recovery registry cleaner router safe mode screen slow sound spyware trojan upgrade video virus vista vundo windows windows 7 windows vista windows xp wireless
Search
Search for:
Tech Support Guy Forums > Software & Hardware > Business Applications >
Printing Page Breaks and Numbers

Tip: Click here to scan for System Errors and Optimize PC performance
[ Sponsored Link ]

Closed Thread
 
Thread Tools
cristobal03's Avatar
Distinguished Member with 2,994 posts.
 
Join Date: Aug 2005
Experience: Advanced
03-Jan-2006, 12: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, 79 views)
File Type: doc Collapse of lorem ipsum sample.doc (36.0 KB, 73 views)
Closed Thread Bookmark and Share

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.

Smart Search

Find your solution!



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


You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -5. The time now is 06:37 AM.
Copyright © 1996 - 2009 TechGuy, Inc. All rights reserved.
Powered by vBulletin, Copyright © 2000 - 2009, Jelsoft Enterprises Ltd.
Powered by Cermak Technologies, Inc.