
Error when running Macro from Global Template
Coz thats where autotext is stored, but it's only available if you go
get it.
Quote:
>Hi Steve,
>Thank you, Thank you, Thank you!
>That work! I have no clue why, but Thank you!!!
>Kerri
>>-----Original Message-----
>>the autotext entry's template needs to be explicitly
>mentioned.
>went like this:
>>>Hi,
>>>I have a macro that is stored as a Global Template
>>>called "Firm.dot". When I use my toolbar button to run
>a
>>>specific macro I get this error: 5914 "..requested
>member
>>>of collection does not exist". The funny thing is this
>>>macro works great as long as the "Firm.dot" template is
>>>open. Any ideas as to why this might be happening.
>>>In my macro I retrieve an "AutoText" entry and insert it
>>>in the Header/Footer.
>>> I provided the code below.
>>>Thank in advance for your time!
>>>Kerri
>>>Sub MSCOFinalizeInsertNumbers()
>>>'Sub PLDMCSOMargins()
>>> With ActiveDocument.Styles(wdStyleNormal).Font
>>> If .NameFarEast = .NameAscii Then
>>> .NameAscii = ""
>>> End If
>>> .NameFarEast = ""
>>> End With
>>> With ActiveDocument.PageSetup
>>> .Orientation = wdOrientPortrait
>>> .TopMargin = InchesToPoints(1.5)
>>> .BottomMargin = InchesToPoints(0.7)
>>> .LeftMargin = InchesToPoints(1.2)
>>> .RightMargin = InchesToPoints(0.5)
>>> End With
>>>'End Sub
>>>'Sub Insertlines()
>>>'Insert Autotext into Primary Header
>>>Dim oRng2 As Range
>>>Set oRng2 = ActiveDocument.Sections(1).Headers
>>>(wdHeaderFooterPrimary).Range
>>>With oRng2
>>>'InsertMCSOLines()
>>> Dim oTemp As Template
>>> Set oTemp = Word.Templates(Options.DefaultFilePath
>>>(wdStartupPath) & "\Firm.dot")
>>> oTemp.AutoTextEntries("Pld21lines(2)").Insert
>>>Where:=oRng2, RichText:=True
>>> End With
>>>' Insert Autotext into Diff. first page
>>>Dim oRng As Range
>>>With ActiveDocument.PageSetup
>>> .DifferentFirstPageHeaderFooter = True
>>> ' .OddAndEvenPagesHeaderFooter = True
>>>End With
>>> Set oRng = ActiveDocument.Sections(1).Headers
>>>(wdHeaderFooterFirstPage).Range
>>>' insert an AutoText from a global template example:
>>>With oRng
>>>' Set oTemp = Templates(Options.DefaultFilePath
>>>(wdStartupPath) & "\Firm.dot")
>>> oTemp.AutoTextEntries("Pld21lines(2)").Insert
>>>Where:=oRng, RichText:=True
>>>End With
>>>End Sub
>>Steve Hudson -- Word Heretic, Sydney, Australia
>>{*filter*} teacher, trainer, tutor, writer, developer
> http://www.*-*-*.com/
>>Word MVP FAQs: http://www.*-*-*.com/
>>You agree by writing to me personally that any material
>can be reused publicly unless you explicitly disclaim it.
>(For List and blog use.)
>>.
Steve Hudson -- Word Heretic, Sydney, Australia
E-tutoring and e-help anytime for hire.
Word MVP FAQs: http://www.*-*-*.com/