Information générale
Catégorie:
COM/DCOM et OLE Automation
Try to use .ActiveDocument.Sections(i) approach instead. Like:
with .ActiveDocument.Sections(1)
.Headers(wdHeaderFooterPrimary).Range.Text = "Header1 text"
.Footers(wdHeaderFooterPrimary).Range.Text = "Footer1 text"
endwith
with .ActiveDocument.Sections(2)
.Headers(wdHeaderFooterPrimary).Range.Text = "Header2 text"
.Footers(wdHeaderFooterPrimary).Range.Text = "Footer2 text"
endwith
>I am working on a large project involving word automation. Due to the lack of documentation of this concept, I am inching along. Maybe someone can help me with this.
>
>I wish to have various sections with different headers / footers in each.
>
>This code is an example of how I am attempting to do this. However, it is not working as expected. Even though I am setting the property LINKTOPREVIOUS as .F.
>
>Any ideas would be appreciated.
>
>
>
>oRange.InsertBreak(wdSectionBreakNextPage)
>
>* Begin Page 4
>* Introduction Letter
>oRange.Collapse(wdCollapseEnd)
>
>FOR j = 1 TO 5
> oRange.InsertAfter(CR)
>endfor
>oRange.InsertAfter(DTOC(DATE()))
>oRange.InsertAfter(CR+CR)
>oRange.InsertAfter("To the Management of ")
>oRange.Font.Name = FONT_NAME_STANDARD
>oRange.Font.Bold = 0
>oRange.Font.Italic = 0
>oRange.Font.Size = FONT_SIZE_STANDARD
>oRange.ParagraphFormat.Alignment = wdAlignParagraphLeft
>oRange.Collapse(wdCollapseEnd)
>
>* Here is where I attempt to change the text for this particular
>* section's header/footer. The Text I "Insert" becomes part of the
>* text that was in the previous section's header/footer.
>
>oHeader = oDoc.Sections.Last.Headers[WdHeaderFooterPrimary]
>oHeader.LinkToPrevious = .F.
>oHeader.Range.InsertAfter("New Header")
>
>oFooter = oDoc.Sections.Last.Footers[WdHeaderFooterPrimary]
>oFooter.LinkToPrevious = .F.
>oFooter.Range.InsertAfter("New Footer")
>
>oRange.Collapse(wdCollapseEnd)
>* End Page 4
Précédent
Suivant
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement