Autotext and Macro and Sharing

M

Mickey

Hi,
I have a template that I would like to share. When I originally wrote it
(thanks to everyone for the help provided) I wrote a macro that called for an
autotext. At the time the autotext was stored in Normal.dot. I created a
new template with the macros and calls out the autotexts. I put the
autotexts in the new template also. I tried to share it but it looks for the
autotext to be in the Normal.dot template and not the new template. The
following is the macro. The new template I created is named "QPACE". I
thought I could change "NormalTemplate.AutoTextEntries("SOP")." to
"QPACETemplate".AutoTextEntries("SOP") and it would work, but it doesn't.
Any suggestions. As always thanks so much for any help provided.

Mickey

Sub AddHeaderSOP()

Dim r As Range
Dim s As Section

For Each s In ActiveDocument.Sections
Set r = s.Headers(wdHeaderFooterPrimary) _
.Range.Paragraphs(1).Range

With r
.ParagraphFormat.TabStops.ClearAll
.ParagraphFormat.TabStops(InchesToPoints(1.25)) _
.Alignment = wdAlignTabLeft
.ParagraphFormat.TabStops(InchesToPoints(6.5)) _
.Alignment = wdAlignTabRight

.Collapse wdCollapseStart
.Collapse wdCollapseEnd

If s.Index = 1 Then
NormalTemplate.AutoTextEntries("SOP").Insert _
Where:=r, RichText:=True
Else
NormalTemplate.AutoTextEntries("SOP2").Insert _
Where:=r, RichText:=True
End If


End With
Next s

End Sub
 
D

David Sisson

Change NormalTemplate.AutoTextEntries... to
ActiveDocument.AttachedTemplate.AutoTextEntries...

or better yet define as a object

Dim MyTemplate As Template

Set MyTemplate = ActiveDocument.AttachedTemplate

MyTemplate.AutoTextEntries...
 
M

Mickey

Thanks David. I tried it both ways and neither worked. Any other suggestions.

Thanks
 
S

Shauna Kelly

Hi Mickey

If the AutoTexts are in the same file as the file that contains the
code, then change
NormalTemplate.AutoTextEntries("SOP").Insert
to
ThisDocument.AutoTextEntries("SOP").Insert

"ThisDocument" refers to the file that contains the code.

Hope this helps.

Shauna Kelly. Microsoft MVP.
http://www.shaunakelly.com/word
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top