F
FMAS
I got part of this from discussion groups. It works fine: It reads
Autotext entries from a table and assign them to normal.dot.
I am trying to assign them to a custom template (eg "mytemplate.dot")
but no way to find the autotext entries in "Mytemplate.dot". I have
assigned the template to the document via Tools > Add-in etc..
Sub AddAutoTextEntries()
Dim oTemplate As Template
Dim tbl As Table
Dim lRow As Long
Dim lRowIx As Long
Dim strId As String
'Define oTemplate
Set oTemplate = ThisDocument.AttachedTemplate '## I have also tried
writing the actual path in full, didn't help
Set tbl = ActiveDocument.Tables(1)
lRow = tbl.Rows.Count
' Schleife über alle Zeilen
For lRowIx = 1 To lRow
' Kürzel auslesen
strId = tbl.Cell(lRowIx, 1).Range.Text
strId = Left$(strId, Len(strId) - 2)
' 2 Spalte auswählen
tbl.Cell(lRowIx, 2).Select
' 1 Schritt zurück, damit das
' Zell-Ende nicht markiert wird
Selection.MoveLeft Unit:=wdCharacter, Count:=1, Extend:=wdExtend
' Autotext-Eintrag hinzufügen
oTemplate.AutoTextEntries.Add Name:=strId,
Range:=Selection.Range '## here is the problem, takes still normal.dot
Next lRowIx
End Sub
Autotext entries from a table and assign them to normal.dot.
I am trying to assign them to a custom template (eg "mytemplate.dot")
but no way to find the autotext entries in "Mytemplate.dot". I have
assigned the template to the document via Tools > Add-in etc..
Sub AddAutoTextEntries()
Dim oTemplate As Template
Dim tbl As Table
Dim lRow As Long
Dim lRowIx As Long
Dim strId As String
'Define oTemplate
Set oTemplate = ThisDocument.AttachedTemplate '## I have also tried
writing the actual path in full, didn't help
Set tbl = ActiveDocument.Tables(1)
lRow = tbl.Rows.Count
' Schleife über alle Zeilen
For lRowIx = 1 To lRow
' Kürzel auslesen
strId = tbl.Cell(lRowIx, 1).Range.Text
strId = Left$(strId, Len(strId) - 2)
' 2 Spalte auswählen
tbl.Cell(lRowIx, 2).Select
' 1 Schritt zurück, damit das
' Zell-Ende nicht markiert wird
Selection.MoveLeft Unit:=wdCharacter, Count:=1, Extend:=wdExtend
' Autotext-Eintrag hinzufügen
oTemplate.AutoTextEntries.Add Name:=strId,
Range:=Selection.Range '## here is the problem, takes still normal.dot
Next lRowIx
End Sub