While Greg's add-in should work if installed correctly (though some of the
buttons do not actually have content and so will do nothing until you
program them to do so) his web page actually points to a solution more in
line with what you had in mind - ie batch insertion of autotext entries,
though his posted code doesn't work to that end
The following macro requires the entries to be saved in a two column table
in a Word document defined at sFname =
The first column contains the 'prompts', the second the text to be entered.
The entries are stored in the normal template - its location defined at Set
oTmp = in the autotext gallery in the category 'Scientific Names'.
The macro doesn't save the normal template so you would need to do that if
you are happy with the result.
Do note that there is no autocomplete for autotext in Word 2007 so you would
need to use memorable and unique autotext names (or you could use
autocorrect instead - there is a method to batch insert autocorrect entries
on the MVPS.ORG web site).
Sub EnterBBProgramatically()
Dim oRng As Word.Range
Dim oTmp As Template
Dim objBB As BuildingBlock
Dim ChangeDoc As Document
Dim cTable As Table
Dim aPrompt As Range, aTextPart As Range
Dim i As Long
Dim sFname As String
Set oTmp = Templates("D:\Word 2007 Templates\Normal.dotm")
sFname = "D:\My Documents\Test\AutoTextTable.doc"
Set ChangeDoc = Documents.Open(sFname)
Set cTable = ChangeDoc.Tables(1)
For i = 1 To cTable.Rows.Count
Set aPrompt = cTable.Cell(i, 1).Range
aPrompt.End = aPrompt.End - 1
Set aTextPart = cTable.Cell(i, 2).Range
aTextPart.End = aTextPart.End - 1
Set objBB = oTmp.BuildingBlockEntries _
.Add(name:=aPrompt, _
Type:=wdTypeAutoText, _
Category:="Scientific Names", _
Range:=aTextPart)
Next i
ChangeDoc.Close wdDoNotSaveChanges
End Sub
http://www.gmayor.com/installing_macro.htm
--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP
My web site
www.gmayor.com
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>