Insert AutoText in Footer via Macro 
Author Message
 Insert AutoText in Footer via Macro

I am trying to insert specific autotext into numerous
footers in a doc.  The doc has about 5 sections and I need
to do each section individually.  I am running into issues
with the code?  Any ideas?


Sun, 18 Jul 2004 01:11:36 GMT  
 Insert AutoText in Footer via Macro
Hi JDH,

How about posting the code? What "issues" are you running into?

HTH

Quote:
> I am trying to insert specific autotext into numerous
> footers in a doc.  The doc has about 5 sections and I need
> to do each section individually.  I am running into issues
> with the code?  Any ideas?



Sun, 18 Jul 2004 01:50:51 GMT  
 Insert AutoText in Footer via Macro
It is ugly, but here it is.  The main issue, is I can't
work with autotext and HeaderFooter in conjunction with
each other.  I am trying to run through each section
(number could vary that is whay I count it) in the
document and insert this autotext.

Sub FaxFix()
ActiveDocument.AttachedTemplate
= "C:\word\startup\macros.dot"
fcount = ActiveDocument.Sections.Count
For acnt = 2 To fcount
       Call FaxFooter(acnt)
Next
End Sub
Sub FaxFooter(acnt):
'    MsgBox "This is section" & acnt

With ActiveDocument.Sections(acnt)

    .Footers (wdHeaderFooterPrimary)
    AttachedTemplate.AutoTextEntries
("2ndPageLetterhead").Insert Where:= _
        Selection.Range, RichText:=True
End With

End Sub

Quote:
>-----Original Message-----
>Hi JDH,

>How about posting the code? What "issues" are you running
into?

>HTH


>> I am trying to insert specific autotext into numerous
>> footers in a doc.  The doc has about 5 sections and I
need
>> to do each section individually.  I am running into
issues
>> with the code?  Any ideas?

>.



Sun, 18 Jul 2004 02:03:26 GMT  
 Insert AutoText in Footer via Macro
Hi JDH,

I think your routine went a little astray with the "Where:=" argument of
your Insert method. You have it trying to insert it at the current selection
without ever _selecting_ (or specifying) the footer range. Instead of trying
to select it, you could just specify the range in the where argument. You
might also want to make sure that you have the LinkToPrevious property set
to False before you start inserting text into the footer range(s). Try the
following, and I think you will be okay (note that this routine first
removes any material that might be in the footer range):

'----------------------------------
Sub FaxFix()
Dim sec As Section
ActiveDocument.AttachedTemplate = "C:\word\startup\macros.dot"
fcount = ActiveDocument.Sections.Count
For Each sec In ActiveDocument.Sections
    With sec.Footers(wdHeaderFooterPrimary)
        ' do not link to the previous footer
        .LinkToPrevious = False
        ' remove any material in the range
        .Range.Text = ""
    End With
Next sec
For acnt = 2 To fcount
       Call FaxFooter(acnt)
Next
End Sub
'----------------------------------

'----------------------------------
Sub FaxFooter(acnt)
With ActiveDocument.Sections(acnt)
    Application.Templates(ActiveDocument.AttachedTemplate) _
    .AutoTextEntries("2ndPageLetterhead").Insert _
        Where:=.Footers(wdHeaderFooterPrimary).Range, _
        RichText:=True
End With
End Sub
'----------------------------------

HTH


Quote:
> It is ugly, but here it is.  The main issue, is I can't
> work with autotext and HeaderFooter in conjunction with
> each other.  I am trying to run through each section
> (number could vary that is whay I count it) in the
> document and insert this autotext.

> Sub FaxFix()
> ActiveDocument.AttachedTemplate
> = "C:\word\startup\macros.dot"
> fcount = ActiveDocument.Sections.Count
> For acnt = 2 To fcount
>        Call FaxFooter(acnt)
> Next
> End Sub
> Sub FaxFooter(acnt):
> '    MsgBox "This is section" & acnt

> With ActiveDocument.Sections(acnt)

>     .Footers (wdHeaderFooterPrimary)
>     AttachedTemplate.AutoTextEntries
> ("2ndPageLetterhead").Insert Where:= _
>         Selection.Range, RichText:=True
> End With

> End Sub

> >-----Original Message-----
> >Hi JDH,

> >How about posting the code? What "issues" are you running
> into?

> >HTH


> >> I am trying to insert specific autotext into numerous
> >> footers in a doc.  The doc has about 5 sections and I
> need
> >> to do each section individually.  I am running into
> issues
> >> with the code?  Any ideas?

> >.



Sun, 18 Jul 2004 02:54:33 GMT  
 Insert AutoText in Footer via Macro
Thank you Dave!  This is great.  New issue, is it does not
appear to be finding the autotext entry????
Quote:
>-----Original Message-----
>Hi JDH,

>I think your routine went a little astray with

the "Where:=" argument of
Quote:
>your Insert method. You have it trying to insert it at

the current selection
Quote:
>without ever _selecting_ (or specifying) the footer

range. Instead of trying
Quote:
>to select it, you could just specify the range in the
where argument. You
>might also want to make sure that you have the

LinkToPrevious property set
Quote:
>to False before you start inserting text into the footer
range(s). Try the
>following, and I think you will be okay (note that this
routine first
>removes any material that might be in the footer range):

>'----------------------------------
>Sub FaxFix()
>Dim sec As Section
>ActiveDocument.AttachedTemplate

= "C:\word\startup\macros.dot"
Quote:
>fcount = ActiveDocument.Sections.Count
>For Each sec In ActiveDocument.Sections
>    With sec.Footers(wdHeaderFooterPrimary)
>        ' do not link to the previous footer
>        .LinkToPrevious = False
>        ' remove any material in the range
>        .Range.Text = ""
>    End With
>Next sec
>For acnt = 2 To fcount
>       Call FaxFooter(acnt)
>Next
>End Sub
>'----------------------------------

>'----------------------------------
>Sub FaxFooter(acnt)
>With ActiveDocument.Sections(acnt)
>    Application.Templates

(ActiveDocument.AttachedTemplate) _

- Show quoted text -

Quote:
>    .AutoTextEntries("2ndPageLetterhead").Insert _
>        Where:=.Footers(wdHeaderFooterPrimary).Range, _
>        RichText:=True
>End With
>End Sub
>'----------------------------------

>HTH



>> It is ugly, but here it is.  The main issue, is I can't
>> work with autotext and HeaderFooter in conjunction with
>> each other.  I am trying to run through each section
>> (number could vary that is whay I count it) in the
>> document and insert this autotext.

>> Sub FaxFix()
>> ActiveDocument.AttachedTemplate
>> = "C:\word\startup\macros.dot"
>> fcount = ActiveDocument.Sections.Count
>> For acnt = 2 To fcount
>>        Call FaxFooter(acnt)
>> Next
>> End Sub
>> Sub FaxFooter(acnt):
>> '    MsgBox "This is section" & acnt

>> With ActiveDocument.Sections(acnt)

>>     .Footers (wdHeaderFooterPrimary)
>>     AttachedTemplate.AutoTextEntries
>> ("2ndPageLetterhead").Insert Where:= _
>>         Selection.Range, RichText:=True
>> End With

>> End Sub

>> >-----Original Message-----
>> >Hi JDH,

>> >How about posting the code? What "issues" are you
running
>> into?

>> >HTH


>> >> I am trying to insert specific autotext into numerous
>> >> footers in a doc.  The doc has about 5 sections and I
>> need
>> >> to do each section individually.  I am running into
>> issues
>> >> with the code?  Any ideas?

>> >.

>.



Sun, 18 Jul 2004 03:42:03 GMT  
 Insert AutoText in Footer via Macro
Hi JDH,

Are you sure the AutoText entry is attached to that template in that
directory?

HTH

Quote:
> Thank you Dave!  This is great.  New issue, is it does not
> appear to be finding the autotext entry????
> >-----Original Message-----
> >Hi JDH,

> >I think your routine went a little astray with
> the "Where:=" argument of
> >your Insert method. You have it trying to insert it at
> the current selection
> >without ever _selecting_ (or specifying) the footer
> range. Instead of trying
> >to select it, you could just specify the range in the
> where argument. You
> >might also want to make sure that you have the
> LinkToPrevious property set
> >to False before you start inserting text into the footer
> range(s). Try the
> >following, and I think you will be okay (note that this
> routine first
> >removes any material that might be in the footer range):

> >'----------------------------------
> >Sub FaxFix()
> >Dim sec As Section
> >ActiveDocument.AttachedTemplate
> = "C:\word\startup\macros.dot"
> >fcount = ActiveDocument.Sections.Count
> >For Each sec In ActiveDocument.Sections
> >    With sec.Footers(wdHeaderFooterPrimary)
> >        ' do not link to the previous footer
> >        .LinkToPrevious = False
> >        ' remove any material in the range
> >        .Range.Text = ""
> >    End With
> >Next sec
> >For acnt = 2 To fcount
> >       Call FaxFooter(acnt)
> >Next
> >End Sub
> >'----------------------------------

> >'----------------------------------
> >Sub FaxFooter(acnt)
> >With ActiveDocument.Sections(acnt)
> >    Application.Templates
> (ActiveDocument.AttachedTemplate) _
> >    .AutoTextEntries("2ndPageLetterhead").Insert _
> >        Where:=.Footers(wdHeaderFooterPrimary).Range, _
> >        RichText:=True
> >End With
> >End Sub
> >'----------------------------------

> >HTH



> >> It is ugly, but here it is.  The main issue, is I can't
> >> work with autotext and HeaderFooter in conjunction with
> >> each other.  I am trying to run through each section
> >> (number could vary that is whay I count it) in the
> >> document and insert this autotext.

> >> Sub FaxFix()
> >> ActiveDocument.AttachedTemplate
> >> = "C:\word\startup\macros.dot"
> >> fcount = ActiveDocument.Sections.Count
> >> For acnt = 2 To fcount
> >>        Call FaxFooter(acnt)
> >> Next
> >> End Sub
> >> Sub FaxFooter(acnt):
> >> '    MsgBox "This is section" & acnt

> >> With ActiveDocument.Sections(acnt)

> >>     .Footers (wdHeaderFooterPrimary)
> >>     AttachedTemplate.AutoTextEntries
> >> ("2ndPageLetterhead").Insert Where:= _
> >>         Selection.Range, RichText:=True
> >> End With

> >> End Sub

> >> >-----Original Message-----
> >> >Hi JDH,

> >> >How about posting the code? What "issues" are you
> running
> >> into?

> >> >HTH


> >> >> I am trying to insert specific autotext into numerous
> >> >> footers in a doc.  The doc has about 5 sections and I
> >> need
> >> >> to do each section individually.  I am running into
> >> issues
> >> >> with the code?  Any ideas?

> >> >.

> >.



Sun, 18 Jul 2004 04:01:26 GMT  
 Insert AutoText in Footer via Macro
Yep, it is contained in the file macros.dot file...maybe I
am attaching it incorrectly.

Quote:
>-----Original Message-----
>Hi JDH,

>Are you sure the AutoText entry is attached to that
template in that
>directory?

>HTH


>> Thank you Dave!  This is great.  New issue, is it does
not
>> appear to be finding the autotext entry????
>> >-----Original Message-----
>> >Hi JDH,

>> >I think your routine went a little astray with
>> the "Where:=" argument of
>> >your Insert method. You have it trying to insert it at
>> the current selection
>> >without ever _selecting_ (or specifying) the footer
>> range. Instead of trying
>> >to select it, you could just specify the range in the
>> where argument. You
>> >might also want to make sure that you have the
>> LinkToPrevious property set
>> >to False before you start inserting text into the
footer
>> range(s). Try the
>> >following, and I think you will be okay (note that this
>> routine first
>> >removes any material that might be in the footer
range):

>> >'----------------------------------
>> >Sub FaxFix()
>> >Dim sec As Section
>> >ActiveDocument.AttachedTemplate
>> = "C:\word\startup\macros.dot"
>> >fcount = ActiveDocument.Sections.Count
>> >For Each sec In ActiveDocument.Sections
>> >    With sec.Footers(wdHeaderFooterPrimary)
>> >        ' do not link to the previous footer
>> >        .LinkToPrevious = False
>> >        ' remove any material in the range
>> >        .Range.Text = ""
>> >    End With
>> >Next sec
>> >For acnt = 2 To fcount
>> >       Call FaxFooter(acnt)
>> >Next
>> >End Sub
>> >'----------------------------------

>> >'----------------------------------
>> >Sub FaxFooter(acnt)
>> >With ActiveDocument.Sections(acnt)
>> >    Application.Templates
>> (ActiveDocument.AttachedTemplate) _
>> >    .AutoTextEntries("2ndPageLetterhead").Insert _
>> >        Where:=.Footers(wdHeaderFooterPrimary).Range, _
>> >        RichText:=True
>> >End With
>> >End Sub
>> >'----------------------------------

>> >HTH



>> >> It is ugly, but here it is.  The main issue, is I
can't
>> >> work with autotext and HeaderFooter in conjunction
with
>> >> each other.  I am trying to run through each section
>> >> (number could vary that is whay I count it) in the
>> >> document and insert this autotext.

>> >> Sub FaxFix()
>> >> ActiveDocument.AttachedTemplate
>> >> = "C:\word\startup\macros.dot"
>> >> fcount = ActiveDocument.Sections.Count
>> >> For acnt = 2 To fcount
>> >>        Call FaxFooter(acnt)
>> >> Next
>> >> End Sub
>> >> Sub FaxFooter(acnt):
>> >> '    MsgBox "This is section" & acnt

>> >> With ActiveDocument.Sections(acnt)

>> >>     .Footers (wdHeaderFooterPrimary)
>> >>     AttachedTemplate.AutoTextEntries
>> >> ("2ndPageLetterhead").Insert Where:= _
>> >>         Selection.Range, RichText:=True
>> >> End With

>> >> End Sub

>> >> >-----Original Message-----
>> >> >Hi JDH,

>> >> >How about posting the code? What "issues" are you
>> running
>> >> into?

>> >> >HTH


>> >> >> I am trying to insert specific autotext into
numerous
>> >> >> { w t rd ?< ??
>V
>footers in a doc.  The doc has about 5 sections and I
>> >> need
>> >> >> to do each section individually.  I am running
into
>> >> issues
>> >> >> with the code?  Any ideas?

>> >> >.

>> >.

>.



Sun, 18 Jul 2004 04:23:14 GMT  
 Insert AutoText in Footer via Macro
Hi JDH,

If it can't find the autotext entry, then either the entry doesn't exist or
it doesn't exist in that template in that directory. Are you getting a
specific error message?


Yep, it is contained in the file macros.dot file...maybe I
am attaching it incorrectly.

Quote:
>-----Original Message-----
>Hi JDH,

>Are you sure the AutoText entry is attached to that
template in that
>directory?

>HTH


>> Thank you Dave!  This is great.  New issue, is it does
not
>> appear to be finding the autotext entry????
>> >-----Original Message-----
>> >Hi JDH,

>> >I think your routine went a little astray with
>> the "Where:=" argument of
>> >your Insert method. You have it trying to insert it at
>> the current selection
>> >without ever _selecting_ (or specifying) the footer
>> range. Instead of trying
>> >to select it, you could just specify the range in the
>> where argument. You
>> >might also want to make sure that you have the
>> LinkToPrevious property set
>> >to False before you start inserting text into the
footer
>> range(s). Try the
>> >following, and I think you will be okay (note that this
>> routine first
>> >removes any material that might be in the footer
range):

>> >'----------------------------------
>> >Sub FaxFix()
>> >Dim sec As Section
>> >ActiveDocument.AttachedTemplate
>> = "C:\word\startup\macros.dot"
>> >fcount = ActiveDocument.Sections.Count
>> >For Each sec In ActiveDocument.Sections
>> >    With sec.Footers(wdHeaderFooterPrimary)
>> >        ' do not link to the previous footer
>> >        .LinkToPrevious = False
>> >        ' remove any material in the range
>> >        .Range.Text = ""
>> >    End With
>> >Next sec
>> >For acnt = 2 To fcount
>> >       Call FaxFooter(acnt)
>> >Next
>> >End Sub
>> >'----------------------------------

>> >'----------------------------------
>> >Sub FaxFooter(acnt)
>> >With ActiveDocument.Sections(acnt)
>> >    Application.Templates
>> (ActiveDocument.AttachedTemplate) _
>> >    .AutoTextEntries("2ndPageLetterhead").Insert _
>> >        Where:=.Footers(wdHeaderFooterPrimary).Range, _
>> >        RichText:=True
>> >End With
>> >End Sub
>> >'----------------------------------

>> >HTH



>> >> It is ugly, but here it is.  The main issue, is I
can't
>> >> work with autotext and HeaderFooter in conjunction
with
>> >> each other.  I am trying to run through each section
>> >> (number could vary that is whay I count it) in the
>> >> document and insert this autotext.

>> >> Sub FaxFix()
>> >> ActiveDocument.AttachedTemplate
>> >> = "C:\word\startup\macros.dot"
>> >> fcount = ActiveDocument.Sections.Count
>> >> For acnt = 2 To fcount
>> >>        Call FaxFooter(acnt)
>> >> Next
>> >> End Sub
>> >> Sub FaxFooter(acnt):
>> >> '    MsgBox "This is section" & acnt

>> >> With ActiveDocument.Sections(acnt)

>> >>     .Footers (wdHeaderFooterPrimary)
>> >>     AttachedTemplate.AutoTextEntries
>> >> ("2ndPageLetterhead").Insert Where:= _
>> >>         Selection.Range, RichText:=True
>> >> End With

>> >> End Sub

>> >> >-----Original Message-----
>> >> >Hi JDH,

>> >> >How about posting the code? What "issues" are you
>> running
>> >> into?

>> >> >HTH


>> >> >> I am trying to insert specific autotext into
numerous
>> >> >> { w t rd ?< ??
>V
>footers in a doc.  The doc has about 5 sections and I
>> >> need
>> >> >> to do each section individually.  I am running
into
>> >> issues
>> >> >> with the code?  Any ideas?

>> >> >.

>> >.

>.



Sun, 18 Jul 2004 05:00:11 GMT  
 Insert AutoText in Footer via Macro
YES!  Got it.  Thank you so much for your help.  Saved me
from going crazy from aggravation.  Just had to make one
minor change to the statement below.

Sub FaxFooter(acnt)
With ActiveDocument.Sections(acnt)
    ActiveDocument.AttachedTemplate.AutoTextEntries
("2ndPageLetterhead").Insert _
        Where:=.Footers(wdHeaderFooterPrimary).Range, _
        RichText:=True
End With
End Sub

THANK YOU :)

Quote:
>-----Original Message-----
>Yep, it is contained in the file macros.dot file...maybe
I
>am attaching it incorrectly.

>>-----Original Message-----
>>Hi JDH,

>>Are you sure the AutoText entry is attached to that
>template in that
>>directory?

>>HTH


>>> Thank you Dave!  This is great.  New issue, is it does
>not
>>> appear to be finding the autotext entry????
>>> >-----Original Message-----
>>> >Hi JDH,

>>> >I think your routine went a little astray with
>>> the "Where:=" argument of
>>> >your Insert method. You have it trying to insert it at
>>> the current selection
>>> >without ever _selecting_ (or specifying) the footer
>>> range. Instead of trying
>>> >to select it, you could just specify the range in the
>>> where argument. You
>>> >might also want to make sure that you have the
>>> LinkToPrevious property set
>>> >to False before you start inserting text into the
>footer
>>> range(s). Try the
>>> >following, and I think you will be okay (note that
this
>>> routine first
>>> >removes any material that might be in the footer
>range):

>>> >'----------------------------------
>>> >Sub FaxFix()
>>> >Dim sec As Section
>>> >ActiveDocument.AttachedTemplate
>>> = "C:\word\startup\macros.dot"
>>> >fcount = ActiveDocument.Sections.Count
>>> >For Each sec In ActiveDocument.Sections
>>> >    With sec.Footers(wdHeaderFooterPrimary)
>>> >        ' do not link to the previous footer
>>> >        .LinkToPrevious = False
>>> >        ' remove any material in the range
>>> >        .Range.Text = ""
>>> >    End With
>>> >Next sec
>>> >For acnt = 2 To fcount
>>> >       Call FaxFooter(acnt)
>>> >Next
>>> >End Sub
>>> >'----------------------------------

>>> >'----------------------------------
>>> >Sub FaxFooter(acnt)
>>> >With ActiveDocument.Sections(acnt)
>>> >    Application.Templates
>>> (ActiveDocument.AttachedTemplate) _
>>> >    .AutoTextEntries("2ndPageLetterhead").Insert _
>>> >        Where:=.Footers(wdHeaderFooterPrimary).Range,
_
>>> >        RichText:=True
>>> >End With
>>> >End Sub
>>> >'----------------------------------

>>> >HTH



>>> >> It is ugly, but here it is.  The main issue, is I
>can't
>>> >> work with autotext and HeaderFooter in conjunction
>with
>>> >> each other.  I am trying to run through each section
>>> >> (number could vary that is whay I count it) in the
>>> >> document and insert this autotext.

>>> >> Sub FaxFix()
>>> >> ActiveDocument.AttachedTemplate
>>> >> = "C:\word\startup\macros.dot"
>>> >> fcount = ActiveDocument.Sections.Count
>>> >> For acnt = 2 To fcount
>>> >>        Call FaxFooter(acnt)
>>> >> Next
>>> >> End Sub
>>> >> Sub FaxFooter(acnt):
>>> >> '    MsgBox "This is section" & acnt

>>> >> With ActiveDocument.Sections(acnt)

>>> >>     .Footers (wdHeaderFooterPr{ w f o g1?0R
e imary)
>>> >>     AttachedTemplate.AutoTextEntries
>>> >> ("2ndPageLetterhead").Insert Where:= _
>>> >>         Selection.Range, RichText:=True
>>> >> End With

>>> >> End Sub

>>> >> >-----Original Message-----
>>> >> >Hi JDH,

>>> >> >How about posting the c



Sun, 18 Jul 2004 05:18:38 GMT  
 
 [ 9 post ] 

 Relevant Pages 

1. Macro that inserts Autotext loses styles of Autotext entry

2. Macro to insert / update footer

3. EZ - Need macro to insert path into footer

4. Macro to insert / update footer

5. Problem with format on insert autotext, and in inserting elements with form fields

6. Updating AutoText in template footer

7. Help Replace Headers Footers w/ Autotext?

8. how to insert a text-file via macro with a specific font

9. Inserting AutoText in Header and retaining formatting

10. Inserting AutoText from a Global Template

11. Insert autotext with VBa

12. Insert Autotext Entries in a Document

 

 
Powered by phpBB® Forum Software