Auto-Creation of Word AutoText Entries to Automatically Link Exhibit References to PDFs
top of page

Auto-Creation of Word AutoText Entries to Automatically Link Exhibit References to PDFs


Tonight I posted a video to my YouTube channel which hopefully provide some help to those who need to create binders of documents referenced in deposition or witness examination outlines. If you can set up a document so an attorney or paralegal can easily hyperlink to any deposition or trial exhibit, you can pull together the documents they need to bring into the courtroom somewhat easier.

The video shows how you can make multiple AutoText entries in MS Word automatically using a macro, which includes hyperlinks. So in the example video each time we enter a reference to an exhibit in the format, "Exhibit 01", etc. we automatically hyperlink to a PDF of the exhibit saved on the C drive.

We first need to automatically add in a hyperlink to all of the documents in our exhibit set.

How to do this using a macro was demonstrated in the Tip of the Night for May 26, 2015. See: http://www.litigationsupporttipofthenight.com/single-post/2015/05/26/How-to-Automate-the-Insertion-of-Hyperlinks-in-MS-Word-8

... but I will show how to do it here again.

The first step is to create a 'concordance' table listing the names of the exhibits in one column and the paths to the PDFs of the exhibits in the second column.

We take the 'concordance' table and save it as a separate Word document in an easy to find location.

We now go to the Reference menu in Word 2010, and then click on Insert Index. In the new dialog box we click Auto Mark.

Then we browse to the Word document with the concordance table. XE codes are added to each exhibit reference with the path for the PDF of the exhibits.

Now we need to edit the MakeHyperlinks macro.

Sub MakeHyperlinks() Dim afield As Field Dim url As String Dim isHyper As Integer

For Each afield In ActiveDocument.Fields If afield.Type = wdFieldIndexEntry Then isHyper = 0 afield.Select Selection.Collapse url = Right$(afield.Code, Len(afield.Code) - 5) url = Left$(url, Len(url) - 2)

If Left$(url, 4) = "../F" Then isHyper = 1 End If

If Left$(url, 4) = "../T" Then isHyper = 2 End If

If isHyper <> 0 Then Selection.MoveStart unit:=wdCharacter, Count:=-3 Selection.MoveStart unit:=wdWord, Count:=-isHyper afield.Delete ActiveDocument.Hyperlinks.Add Anchor:=Selection.Range, _ Address:=url End If End If

Next afield

End Sub


On the path with the reference to the directory containing the PDFs: If Left$(url, 13) = "C:\exhibits\P" Then We need to confirm that only the first letter of the folder containing the PDFs is present in the reference path, and the number given at Left$(url, 13), matches the length of the directory when only the first letter of that last folder is counted.

Now when we run the macro the hyperlinks will be automatically inserted.

The next step is to use the macro to add the hyperlinks we created into Word's AutoText so that each time we type "Exhibit 01"; "Exhibit 02"; and so forth a link is created. We need to create a list with the term want to create an auto-link for and the hyperlinked reference after it, followed by the next term, and the next hyperlinked reference, and so on.

After repeating the exhibit references above the hyperlinked list, we select all, and then sort the list in order using the Sort tool on the Home tab.

Now be sure to put the cursor at the beginning of the list.

We now turn to the macro which will add autotext entries, and run it.

Sub Macro1() ' ' Macro1 Macro 6/18/2012 by Timothy ' Dim p As Paragraph, s As String For Each p In ActiveDocument.Paragraphs If Len(p.Range) < 2 Then GoTo nextone Selection.EndKey Unit:=wdLine, Extend:=wdExtend s = Selection Selection.MoveDown Unit:=wdParagraph, Count:=1, Extend:=wdMove Selection.EndKey Unit:=wdLine, Extend:=wdExtend NormalTemplate.AutoTextEntries.Add Name:=s, Range:=Selection.Range Selection.MoveDown Unit:=wdParagraph, Count:=1, Extend:=wdMove nextone: Next p MsgBox "Done"

End Sub

THANKS TO TIMOTHY FOR CREATING THIS MACRO!

Now when we type an exhibit reference, and then press F3, a link to the PDF of the exhibit will be added.

You can go back to an exhibit reference that you previously entered and still press F3 to add the link.

These hyperlinked autotext entries will be available when you restart Word later to create a new document.


bottom of page