Error when running Macro from Global Template 
Author Message
 Error when running Macro from Global Template

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



Sun, 15 May 2005 06:24:02 GMT  
 Error when running Macro from Global Template

the autotext entry's template needs to be explicitly mentioned.


Quote:
>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

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.)


Fri, 20 May 2005 16:09:43 GMT  
 Error when running Macro from Global Template
Hi Steve,

Thank you, Thank you, Thank you!
That work!  I have no clue why, but Thank you!!!
Kerri

Quote:
>-----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/
Quote:
>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.)

- Show quoted text -

Quote:
>.



Sat, 21 May 2005 02:33:26 GMT  
 Error when running Macro from Global Template
You must also take care to check that the number of documents in the
Documents collection > 0.   In your code you have references to the
ActiveDocument.

You have to be sure that there is an ActiveDocument.

Regards
  Malc



Sat, 21 May 2005 03:24:55 GMT  
 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/


Wed, 27 Jul 2005 16:03:10 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Running an auto macro from global template.

2. Refering to Functions and Subs held in one global template from another global template

3. Macro to call style from global template

4. Workaround for AUTO*-macros in GLOBAL Template?

5. Global.MPT and Enterprise Global Template

6. Is it possible to trigger an event when a template is loaded as a global template

7. Run Macro from Global Enterprise ?

8. Macro runs OK in normal, not in global

9. FileSave macro won't run in template

10. Running a macro from a template

11. Running a macro when template opened?

12. Running macro inside a template document

 

 
Powered by phpBB® Forum Software