Microsoft Office Forums Convert manual cross references in footnotes to other footnotes to automatic cross references

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 11-17-2014, 12:42 AM
ghumdinger ghumdinger is offline Convert manual cross references in footnotes to other footnotes to automatic cross references Windows 7 Convert manual cross references in footnotes to other footnotes to automatic cross references Office 2010 (Version 14.0)
Advanced Beginner
Convert manual cross references in footnotes to other footnotes to automatic cross references
 
Join Date: Jul 2010
Posts: 65
ghumdinger is on a distinguished road
Default Convert manual cross references in footnotes to other footnotes to automatic cross references

I am trying to devise a workflow to convert manual cross references in footnotes to other footnotes to automatic cross references. Due to a limitation in Word's Find and Replace in replacing with field codes, I am stuck. I understand that Find and Replace opertions can be performed with a macro without the limitation.



I have very limited ability in VBA coding, and I appreciate any help I can get.

My workflow comrpises of the following steps:

1. Make bookmarks of all footnote references in the body text using a modified version of the macro posted by MattP at wordbanter at http://www.wordbanter.com/showthread.php?t=124842)

The bookmarks created are named "Bookmark 1", "Bookmark 2" and so on and match the numbering of the footnote reference.

2. Now I need to replace all instances of the manual cross refs in the footnotes with the { FTNREF Bookmark X } field code. The manual cross refs follow this notation consistently: "see n X".

The problem is that Word's Find and Replace only recognize the field opening and closing braces "^d" in the Find box, but not in the Replace box.

The best I can do is to copy the "{FTNREF Bookmark" field (it this partial form) to clipboard, and then replace "see n" with "^c".

But I need the number that comes after the "see n" to be within the field code after "Bookmark". So for e.g. "see n 8", would be replaced with "{FTNREF Bookmark8}". The problem is that after I replace replace "see n" with "^c", the number that comes after "see n" is outside of the "{FTNREF Bookmark" field code.

Can anyone help with a macro to do such a find and replace operation?


Thanks.
Reply With Quote
  #2  
Old 11-17-2014, 05:15 AM
macropod's Avatar
macropod macropod is offline Convert manual cross references in footnotes to other footnotes to automatic cross references Windows 7 64bit Convert manual cross references in footnotes to other footnotes to automatic cross references Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 19,482
macropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to behold
Default

I can't see the point of bookmarking all the footnotes, since Word creates its own when you insert cross-references to them, which you ordinarily do via a NOTEREF field.

A macro to do what you're after using Word's own footnote referencing is:
Code:
Sub ActivateFootNoteCrossRefs()
Dim SBar As Boolean
Dim TrkStatus As Boolean
Dim Rng As Range, i As Long, StrNt As String
' Store current Status Bar status, then switch on
SBar = Application.DisplayStatusBar
Application.DisplayStatusBar = True
' Store current Track Changes status, then switch off
With ActiveDocument
  TrkStatus = .TrackRevisions
  .TrackRevisions = False
End With
' Turn Off Screen Updating
Application.ScreenUpdating = False
With ActiveDocument
  ' Process all footnotes
  For i = 1 To .Footnotes.Count
    ' Update the statusbar
    StatusBar = "Processing Footnote " & i
    Set Rng = .Footnotes(i).Range
    With .Footnotes(i).Range
      With .Find
        .ClearFormatting
        .Replacement.ClearFormatting
        .Text = "see n [0-9]{1,}"
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindStop
        .Format = False
        .MatchWildcards = True
        .Execute
      End With
      Do While .Find.Found
        If .Duplicate.InRange(Rng) Then
          StrNt = Split(.Duplicate.Text, " ")(2)
          ' To replace the "see n " text as well as the number with
          ' a formatted footnote reference, delete/comment-out the next
          ' line and change wdFootnoteNumber to wdFootnoteNumberFormatted 
          .Start = .Words(3).Start
          .InsertCrossReference ReferenceType:=wdRefTypeFootnote, _
            ReferenceKind:=wdFootnoteNumber, ReferenceItem:=StrNt
          .Collapse wdCollapseEnd
          .Find.Execute
        Else
          Exit Do
        End If
      Loop
    End With
  Next
  ' Update the statusbar
  StatusBar = "Finished Processing " & .Footnotes.Count & " Footnotes"
End With
Set Rng = Nothing
' Restore original Status Bar status
Application.DisplayStatusBar = SBar
' Restore original Track Changes status
ActiveDocument.TrackRevisions = TrkStatus
' Restore Screen Updating
Application.ScreenUpdating = True
End Sub
__________________
Cheers,
Paul Edstein
[MS MVP - Word]
Reply With Quote
  #3  
Old 11-17-2014, 05:19 AM
macropod's Avatar
macropod macropod is offline Convert manual cross references in footnotes to other footnotes to automatic cross references Windows 7 64bit Convert manual cross references in footnotes to other footnotes to automatic cross references Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 19,482
macropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to behold
Default

Cross-posted at: http://www.vbaexpress.com/forum/show...ith-field-code
For cross-posting etiquette, please read: http://www.excelguru.ca/content.php?184
__________________
Cheers,
Paul Edstein
[MS MVP - Word]
Reply With Quote
  #4  
Old 11-18-2014, 01:36 AM
ghumdinger ghumdinger is offline Convert manual cross references in footnotes to other footnotes to automatic cross references Windows 7 Convert manual cross references in footnotes to other footnotes to automatic cross references Office 2010 (Version 14.0)
Advanced Beginner
Convert manual cross references in footnotes to other footnotes to automatic cross references
 
Join Date: Jul 2010
Posts: 65
ghumdinger is on a distinguished road
Default

Dear Paul,

Thanks for your help.

First, apologies for the breach of etiquette in cross posting. I did not realize there was a norm against it.

The reason why I used bookmarks instead of footnote cross references was simply because I did not know how to batch create the latter by macro, and I found a macro that uses the former.

I tried your macro on a simple test page. Unfortunately, it did not seem to work - with or without changing wdFootnoteNumber to wdFootnoteNumberFormatted

I've taken a screenshot of the page


In this test doc, the cross references in the footnotes to other footnotes are manually typed in. I am trying to convert them to automatic cross references.
Reply With Quote
  #5  
Old 11-18-2014, 04:06 AM
macropod's Avatar
macropod macropod is offline Convert manual cross references in footnotes to other footnotes to automatic cross references Windows 7 64bit Convert manual cross references in footnotes to other footnotes to automatic cross references Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 19,482
macropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to behold
Default

Your screenshot displays as simply a boxed X. The code works fine for what you described in your post. It replaces all instances of 'see n X' in footers, where X is a number.

Since you're not getting the results you desire, perhaps you could attach a document to a post with some representative data (delete anything sensitive)? You do this via the paperclip symbol on the 'Go Advanced' tab at the bottom of this screen.
__________________
Cheers,
Paul Edstein
[MS MVP - Word]
Reply With Quote
  #6  
Old 11-19-2014, 12:32 AM
ghumdinger ghumdinger is offline Convert manual cross references in footnotes to other footnotes to automatic cross references Windows 7 Convert manual cross references in footnotes to other footnotes to automatic cross references Office 2010 (Version 14.0)
Advanced Beginner
Convert manual cross references in footnotes to other footnotes to automatic cross references
 
Join Date: Jul 2010
Posts: 65
ghumdinger is on a distinguished road
Default

Hi Paul,

This is the doc which I ran your marco on.

I created this test doc just to narrow down why the macro wasn't working in the other longer, more complicated doc.

It doesn't seem to be converting the manual footnote references to the cross reference fields in this simple test doc as well.

Regards,
Jay
Attached Files
File Type: docx 2. Simple test doc - Copy.docx (28.1 KB, 3 views)
Reply With Quote
  #7  
Old 11-19-2014, 12:47 AM
macropod's Avatar
macropod macropod is offline Convert manual cross references in footnotes to other footnotes to automatic cross references Windows 7 64bit Convert manual cross references in footnotes to other footnotes to automatic cross references Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 19,482
macropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to behold
Default

The simple reason is that your document content differs from the description in your post. The Find expression is case-sensitive, to match the lower-case "see n" mentioned three times in your original post. That isn't the same as the "See n" in your document. You can process both by changing:
.Text = "see n [0-9]{1,}"
to:
.Text = "[Ss]ee n [0-9]{1,}"
__________________
Cheers,
Paul Edstein
[MS MVP - Word]
Reply With Quote
  #8  
Old 11-20-2014, 11:47 PM
ghumdinger ghumdinger is offline Convert manual cross references in footnotes to other footnotes to automatic cross references Windows 7 Convert manual cross references in footnotes to other footnotes to automatic cross references Office 2010 (Version 14.0)
Advanced Beginner
Convert manual cross references in footnotes to other footnotes to automatic cross references
 
Join Date: Jul 2010
Posts: 65
ghumdinger is on a distinguished road
Default

Dear Paul,

It works brilliantly. Thank you. Much obliged.

Regards,
Jay
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Convert manual cross references in footnotes to other footnotes to automatic cross references Automatically updating cross-references in Footnotes jessy_33 Word 1 05-07-2014 02:45 PM
Convert manual cross references in footnotes to other footnotes to automatic cross references Bookmarks & cross-references Suchoklates Word 1 09-19-2013 02:32 AM
Convert manual cross references in footnotes to other footnotes to automatic cross references Cross-References acolussi Word 9 05-16-2013 02:11 AM
Cross References not hyperlinked in .HTM GreyOne Word 2 03-08-2013 01:35 AM
Cross References egcharles Office 0 04-19-2009 06:20 AM


All times are GMT -7. The time now is 10:28 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2019, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2019 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft