Page 1 of 2 12 LastLast
Results 1 to 15 of 18
  1. #1
    Bronze Lounger
    Join Date
    Jan 2001
    Location
    Melbourne, Australia
    Posts
    1,294
    Thanks
    0
    Thanked 0 Times in 0 Posts

    track changes code (Word 2002 XP SR3)

    Ive been working on my track changes code Post: 664884

    Ive come across the following scenario.

    the next lot of track changes is a big chunk of text that spans across 2 pages and contained within a table.

    When I use the following code; the code loops on this lot of "track changes". it kinda gets stuck (although i dont know why) <img src=/S/doh.gif border=0 alt=doh width=15 height=15>

    Set revTemp = Selection.NextRevision(Wrap:=False)

    if I use the following code; it works

    WordBasic.NextChangeorComment

    ...however when it comes to the last track change in the doc, and attempts to goto the next track change, the following Word warning message appears:
    "Do you want to continue searching from the beginning of the document?" OK/Cancel

    Any ideas to get past either, or both issues?

    thank you
    diana
    Attached Images Attached Images

  2. #2
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    5,055
    Thanks
    2
    Thanked 417 Times in 346 Posts

    Re: track changes code (Word 2002 XP SR3)

    Hi Diana,

    Perhaps you could do something like:

    <code>Sub PrintChanges()
    Dim Rev As Revision
    Dim PMin As Integer
    Dim PTmp As Integer
    Dim PMax As Integer
    PMin = 0
    PTmp = 0
    PMax = 0
    For Each Rev In ActiveDocument.Revisions
    If Rev.Range.Information(wdActiveEndPageNumber) > PMax Then
    PTmp = PMax
    Rev.Range.Select
    With Selection
    PMax = .Information(wdActiveEndPageNumber)
    .Collapse (wdCollapseStart)
    If PTmp < .Information(wdActiveEndPageNumber) Then
    PMin = .Information(wdActiveEndPageNumber)
    Else
    PMin = PTmp + PTmp < PMax
    End If
    End With
    ActiveDocument.PrintOut Pages:="""" & PMin & " - " & PMax & """"
    End If
    Next
    End Sub</code>
    Cheers,

    Paul Edstein
    [MS MVP - Word]

  3. #3
    Silver Lounger
    Join Date
    Jul 2001
    Location
    Ottawa, Ontario, Canada
    Posts
    1,609
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: track changes code (Word 2002 XP SR3)

    Hi Diana
    FWIW Word seems to be unable to select less than complete cells when more than one cell is involved. Consequently when looping through documents I find that tables frequently enter into an endless loop unless the following line of code is present.

    Selection.Collapse(wdCollapseEnd)
    Regards
    Don

  4. #4
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Re: track changes code (Word 2002 XP SR3)

    Diana,

    You could shorten that code, and avoid doing the selection, with
    <code>
    lngLastPage = ActiveDocument.Revisions(ActiveDocument.Revisions. Count).Range.Information (wdActiveEndPageNumber)
    </code>

    StuartR

  5. #5
    Bronze Lounger
    Join Date
    Jan 2001
    Location
    Melbourne, Australia
    Posts
    1,294
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: track changes code (Word 2002 XP SR3)

    Hi MacroPod

    Thank you for your help.

    I got around this by obtaining the last page of the the last track change with the following code, and used that as a condition to check if the currentPage = the LastPage

    'get page number of last track changes
    'this will be used to end code
    ActiveDocument.Bookmarks("EndOfDoc").Select
    WordBasic.PreviousChangeOrComment
    Selection.EndKey Unit:=wdLine
    lngLastPage = Selection.Information(wdActiveEndPageNumber)


    thank you again Macropod

    diana

  6. #6
    Bronze Lounger
    Join Date
    Jan 2001
    Location
    Melbourne, Australia
    Posts
    1,294
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: track changes code (Word 2002 XP SR3)

    Don - thankyou for the explaination.

    I did use the following code, so the selection would collapse at the start, but it still got stuck within the table cell & wouldnt go past it...

    Set revTemp = Selection.NextRevision(Wrap:=False)
    If Not (revTemp Is Nothing) Then
    Selection.Collapse Direction:=wdCollapseStart

    Stewart - thank you for the code

    diana

  7. #7
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Re: track changes code (Word 2002 XP SR3)

    Was there a reason that you used wdCollapseStart, rather than the suggested wdCollapseEnd?

    StuartR

  8. #8
    Bronze Lounger
    Join Date
    Jan 2001
    Location
    Melbourne, Australia
    Posts
    1,294
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: track changes code (Word 2002 XP SR3)

    yes because the track change "block of text" went over 2 pages within the table. I used collapse start to obtain the page number of the track changes start, then had code to goto the next page & next track changes.

    Had I used collapse end, it would have missed the start ing page number and just picked up the end selection page number

    diana

  9. #9
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Re: track changes code (Word 2002 XP SR3)

    Diana,

    Your code would be much better if you avoided using Selections altogether.

    You can get a list of the start and end pages of all tracked changes using code like I showed you in <post:=664,896>post 664,896</post:>
    I'm sure some of our really clever loungers could simplify this, but the following code will give you an array showing the start and end page of each tracked change or comment.

    StuartR

    <code>
    Sub GetChanges()
    Dim rev As Revision
    Dim cmnt As Comment
    Dim rngStart As Range
    Dim intPages() As Double
    Dim intRevCount As Integer

    intRevCount = ActiveDocument.Revisions.Count + ActiveDocument.Comments.Count
    ReDim intPages(intRevCount, 2)
    intRevCount = 0

    For Each rev In ActiveDocument.Revisions
    intRevCount = intRevCount + 1
    Set rngStart = ActiveDocument.Range(Start:=rev.Range.Start, End:=rev.Range.Start)
    intPages(intRevCount, 1) = rngStart.Information(wdActiveEndPageNumber)
    intPages(intRevCount, 2) = rev.Range.Information(wdActiveEndPageNumber)
    Next rev

    For Each cmnt In ActiveDocument.Comments
    intRevCount = intRevCount + 1
    Set rngStart = ActiveDocument.Range(Start:=cmnt.Reference.Start, End:=cmnt.Reference.Start)
    intPages(intRevCount, 1) = rngStart.Information(wdActiveEndPageNumber)
    intPages(intRevCount, 2) = cmnt.Reference.Information(wdActiveEndPageNumber)
    Next cmnt
    Set rngStart = Nothing
    <font color=448800>
    ' the array intPages now has the start and end page of each tracked change or comment.
    ' start pages are at intPages(i,1), end pages are at intPages(i,2)
    </font color=448800>
    End Sub

    </code>

  10. #10
    Bronze Lounger
    Join Date
    Jan 2001
    Location
    Melbourne, Australia
    Posts
    1,294
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: track changes code (Word 2002 XP SR3)

    Thanks Stewart - Ill take a look at the code.

    I remember reading a Lounge post that there was an issue with working with ranges, I cant remember the exact details, since then I've used Selection

    diana

  11. #11
    Bronze Lounger
    Join Date
    Jan 2001
    Location
    Melbourne, Australia
    Posts
    1,294
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: track changes code (Word 2002 XP SR3)

    Stewart

    I ran that code, the code is pretty neat thank you <img src=/S/smile.gif border=0 alt=smile width=15 height=15>

    I noticed each time you provided sample code you used both revisions and comments.

    running that code on both revisions and comments, returned identical data

    I thought track changes were just track changes but Im guessing revisions and comments are different.

    diana

  12. #12
    Bronze Lounger
    Join Date
    Jan 2001
    Location
    Melbourne, Australia
    Posts
    1,294
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: track changes code (Word 2002 XP SR3)

    Ive picked up the track changes code again...

    I'm now testing.

    The document im working on is 135 pages made up of 31 sections.

    the code goes to the first track changes and obtains the page number.
    on the Word screen bottom bar it displays as (see screen capture)
    Page 6 Sec 5 12/135.

    when i use the code

    intPage = revTemp.Range.Information(wdActiveEndPageNumber)

    it returns the page number "12"

    I store the page numbers in an array.

    and I send this page number "12" to the printer.

    if i step thru the code, the page the code went to doesnt print out, it misses this page.
    Instead, the page it prints display page "12" however on screen this page displays as
    Page 12 Sec 8 18/135

    how do you I interprett the page numbers displayed on the bottom bar?
    do i need to obtain the section number and page number and send these values to the printer?
    any ideas how i can get the correct pages to print.

    diana
    Attached Images Attached Images

  13. #13
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: track changes code (Word 2002 XP SR3)

    You can convert "physical" page numbers to the "logical" page numbers needed for printing using a little range trickery. See this post for an example: Print selection of pages across section breaks (AKA <post#=204230>post 204230</post#>).

  14. #14
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: track changes code (Word 2002 XP SR3)

    Probably there should not be a 1 at the beginning of that string. Perhaps that is just an artifact of posting here.

    I'm not sure whether you are getting this error in every document, or just for a document with a large number of changed pages. I've never tried to figure out what the limit might be for the number of pages you can feed that method. Is it possible to paste that string into the print dialog or does it cut off?

  15. #15
    Bronze Lounger
    Join Date
    Jan 2001
    Location
    Melbourne, Australia
    Posts
    1,294
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: track changes code (Word 2002 XP SR3)

    thank you

    i used the code to obtain the page numbers.

    My page number string is made of up the page numbers and section numbers eg

    totalPages = "1p1s1,p6s5,p9s7,p10s8,p11s8,p12s8,p13s8,p14s8,p15 s8,p16s8,p17s8,p18s8,p19s8,
    p20s8,p21s8,p22s8,p23s8,p24s8,p25s8,p26s8,p27s8,p2 9s8,p30s8,p31s8,p32s8,p33s8,p34s8,p35s8,
    p36s8,p37s8,p38s8,p39s8,p40s8,p41s8,p42s8,p43s8,p4 4s8,p45s8,p46s8,p47s8,p49s8,p50s8,p51s8,
    p52s8,p53s8,p54s8,p55s8,p56s8,p58s8,p90s20,p111s27 "

    gPages = totalPages

    so I send to the printer via the following code...

    Application.PrintOut FileName:="", Copies:=giNumCopies, Range:=gRange, Pages:=gPages, _
    Collate:=True, Background:=False, PrintToFile:=True, OutputFileName:=strFileName, _
    PrintZoomColumn:=lngZoomColumn, PrintZoomRow:=lngZoomRow, PrintZoomPaperWidth:=0, _
    PrintZoomPaperHeight:=0

    an error displays
    Run-tme error '5148' The number must be between -32765 and 32767.

    is this a valid value to send to my page numbers? is this even allowed?


    thank you
    diana
    Attached Images Attached Images

Page 1 of 2 12 LastLast

Posting Permissions

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