Results 1 to 8 of 8
  1. #1
    4 Star Lounger
    Join Date
    Jan 2002
    Location
    London, Gtr London, England
    Posts
    416
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi

    Is it possible to automate this process? I have several documents (will get several more on a regular basis) where I have to insert cross references in a table to the changes in the document. Of course, track changes is easier but unfortunately not available on these docs. So the idea is that we have a table with a list of references to the changes in the document and the reader would be able to click on the reference & get to the change. Doing this manually is not only time consuming but kills brain cells as well.

    Is there an easy to do this? I have put in page numbers for my use at the moment but not necessary. I would be grateful for any ideas as this is killing me to boredom.

    Code:
    Section
    4.1.1 (p10)
    4.2.1 (p11)
    4.3.1 (p12)
    4.6.1 (p13)
    4.7.1 (p14)
    4.8.1 (p15)
    4.9.1 (p16-17)
    4.10. (p18-19)
    4.11.1 (p19), 4.11.2 (p19)
    5.2.2 (p20)
    5.4.2 (p22)
    5.5.2 (p23)
    5.6.2 (p24)
    5.13.2 (p30-31)
    5.14.2 (p32-33)
    5.18 to 5.22
    5.23 (p39)
    6.2 (p41)
    8.1.2 (p45)
    9.2.2 (p48)
    9.4.2 (p50)
    9.5, 9.6
    9.7.2 (p52)
    9.8.2 (p53)
    9.9
    9.10.2 (p56)
    9.15, 9.16
    Thanks.
    Robie

  2. #2
    WS Lounge VIP
    Join Date
    Dec 2009
    Location
    Earth
    Posts
    8,172
    Thanks
    47
    Thanked 980 Times in 910 Posts
    The cross ref / TOC uses a style to determine where to add a reference. If the changes are all in the same style you may be stuck.

    cheers, Paul

  3. #3
    Super Moderator
    Join Date
    Jan 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    3,852
    Thanks
    4
    Thanked 259 Times in 239 Posts
    Note that this solution doesn't attempt to deal with the special cases in your sample where it appears that more than one revision is listed on a single line. Nor does the code attempt to merge into a single revision a replacement type revision (replace = delete + add)

    If you have numbered every paragraph then the following code would do pretty much what you asked.
    Code:
    Sub CompileRevisionsTable()
      Dim aRev As Revision, x As Integer, y As String
      'put cursor at end of document to insert the reference table
      Selection.EndKey Unit:=wdStory
      ActiveDocument.TrackRevisions = False
      
      For x = 1 To ActiveDocument.Revisions.Count
        With ActiveDocument
          .Bookmarks.Add Name:="Rev" & x, Range:=.Revisions(x).Range
          .Fields.Add Range:=Selection.Range, text:="ref Rev" & x & " \r \h"
          Selection.TypeText vbTab & "(p "
          .Fields.Add Range:=Selection.Range, text:="pageref Rev" & x & " \r \h"
          Selection.TypeText ")" & vbCr
        End With
      Next x
    End Sub
    However, if the paragraph numbers in your compiled table refer to the nearest preceding heading number above the revision then the code would need to be trickier.
    Andrew Lockton, Chrysalis Design, Melbourne Australia

  4. #4
    4 Star Lounger
    Join Date
    Jan 2002
    Location
    London, Gtr London, England
    Posts
    416
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Andrew Lockton View Post
    Note that this solution doesn't attempt to deal with the special cases in your sample where it appears that more than one revision is listed on a single line. Nor does the code attempt to merge into a single revision a replacement type revision (replace = delete + add)

    If you have numbered every paragraph then the following code would do pretty much what you asked.
    Code:
    Sub CompileRevisionsTable()
      Dim aRev As Revision, x As Integer, y As String
      'put cursor at end of document to insert the reference table
      Selection.EndKey Unit:=wdStory
      ActiveDocument.TrackRevisions = False
      
      For x = 1 To ActiveDocument.Revisions.Count
        With ActiveDocument
          .Bookmarks.Add Name:="Rev" & x, Range:=.Revisions(x).Range
          .Fields.Add Range:=Selection.Range, text:="ref Rev" & x & " \r \h"
          Selection.TypeText vbTab & "(p "
          .Fields.Add Range:=Selection.Range, text:="pageref Rev" & x & " \r \h"
          Selection.TypeText ")" & vbCr
        End With
      Next x
    End Sub
    However, if the paragraph numbers in your compiled table refer to the nearest preceding heading number above the revision then the code would need to be trickier.
    Thanks Andrew. That is very good indeed. It does most of the things I need so I will go with it.

    Thanks again - very useful.
    Thanks.
    Robie

  5. #5
    4 Star Lounger
    Join Date
    Jan 2002
    Location
    London, Gtr London, England
    Posts
    416
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by robie View Post
    Thanks Andrew. That is very good indeed. It does most of the things I need so I will go with it.

    Thanks again - very useful.
    I wrote too soon. It seemed to work fine for one document but having tried on other docs, I am afraid to say it doesn't work :-(. It comes up with 0 & Page 10 for everything.
    Thanks.
    Robie

  6. #6
    Super Moderator
    Join Date
    Dec 2000
    Location
    New York, NY
    Posts
    2,970
    Thanks
    3
    Thanked 29 Times in 27 Posts
    Andrew: That's a superb piece of code, but a Revisions collection will only be available in a document if revisions have been made when change tracking is enabled. If track changes is not available on these docs per Robie's first post, then the Revisions count is always going to be 0.

    Robie: Can you elucidate what you mean by track changes not being available on these docs? Do you have a group policy that makes track changes unavailable? Or do you mean that you have existing documents in which revisions were made without track changes turned on, and you would now like to build an index of the revisions made in those documents?

    Either way, I don't think you can build an index of revisions, without first making the revisions with track changes, and then using a solution like Andrew's - because without track changes, revisions made are not going to have been marked in any way for subsequent identification.

    Gary

  7. #7
    4 Star Lounger
    Join Date
    Jan 2002
    Location
    London, Gtr London, England
    Posts
    416
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Gary Frieder View Post
    Andrew: That's a superb piece of code, but a Revisions collection will only be available in a document if revisions have been made when change tracking is enabled. If track changes is not available on these docs per Robie's first post, then the Revisions count is always going to be 0.

    Robie: Can you elucidate what you mean by track changes not being available on these docs? Do you have a group policy that makes track changes unavailable? Or do you mean that you have existing documents in which revisions were made without track changes turned on, and you would now like to build an index of the revisions made in those documents?

    Either way, I don't think you can build an index of revisions, without first making the revisions with track changes, and then using a solution like Andrew's - because without track changes, revisions made are not going to have been marked in any way for subsequent identification.

    Gary
    Sorry, been busy with other things lately. Gary: will come back to your question some time later.
    Thanks.
    Robie

  8. #8
    Super Moderator
    Join Date
    Jan 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    3,852
    Thanks
    4
    Thanked 259 Times in 239 Posts
    Robie

    If the paragraph with the tracked revision is NOT numbered automatically then the cross reference to the paragraph number will always show 0. I was hoping you had numbered EVERY paragraph which had a revision (note the caveats on my first post). The page number should have been correct though so I am not sure why you are only getting page 10 unless all your tracked revisions are on this page.

    The code to cross refer to the nearest preceding numbered heading is going to be a bunch more difficult and if you haven't used automatic numbers on headings then it may be trickier again. Your original request had some very odd variations that I wouldn't even want to consider
    4.8.1 (p15) my code only offered this variant
    4.9.1 (p16-17) spanning pages is more complicated
    4.11.1 (p19), 4.11.2 (p19) merging numbers that fall on the same page on the same line?
    5.18 to 5.22 why don't you want a page number here?
    9.5, 9.6 why don't you want a page number here?
    Andrew Lockton, Chrysalis Design, Melbourne Australia

Posting Permissions

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