"Anne Richmond" <an***********@bradford.gov.uk>'s wild
thoughts were released on Tue, 28 Sep 2004 15:17:06 +0100
bearing the following fruit:
The following code creates a word document.
How do I add a footer to each page containing the date and page number?
Dim wrdApp As Word.Application
Dim wrdDoc As Word.Document
Dim wrdSelection As Word.Selection
Dim mText As String
Dim mSub As Integer
wrdApp = CreateObject("Word.Application")
wrdDoc = wrdApp.Documents.Add()
wrdDoc.Select()
wrdSelection = wrdApp.Selection
wrdSelection.ParagraphFormat.Alignment =
Word.WdParagraphAlignment.wdAlignParagraphCente r
wrdSelection.TypeText("New Cases")
wrdSelection.TypeParagraph()
wrdSelection.ParagraphFormat.Alignment =
Word.WdParagraphAlignment.wdAlignParagraphLeft
wrdSelection.TypeParagraph()
wrdSelection.TypeParagraph()
For mSub = 0 To 50
mText = "Line " & mSub
wrdSelection.TypeText(mText)
wrdSelection.TypeParagraph()
Next
wrdApp.Visible = True
I know very little about word in this respect but a little
playing around
wrdApp.Visible = True
If wrdDoc.ActiveWindow.ActivePane.View.Type =
Word.WdViewType.wdNormalView Or
wrdDoc.ActiveWindow.ActivePane.View.Type =
Word.WdViewType.wdOutlineView Then
wrdDoc.ActiveWindow.ActivePane.View.Type =
Word.WdViewType.wdPrintView
End If
wrdDoc.ActiveWindow.ActivePane.View.SeekView =
Word.WdSeekView.wdSeekCurrentPageFooter
wrdApp.Selection.Fields.Add(wrdApp.Selection.Range ,
Word.WdFieldType.wdFieldDate)
wrdApp.Selection.Fields.Add(wrdApp.Selection.Range ,
Word.WdFieldType.wdFieldPage)
However, I always suggest that you record a macro in word
then do whatever it is you require and look at the code that
is produced. Usually the generated code can easily be used
in your VB app.
Playing around with the activepane can be (excuse the pun) a
real pain
Jan Hyde (VB MVP)
--
Did you hear about the group of geometry teachers who started a motorcycle club?
Hell's Angles. (KM)
[Abolish the TV License -
http://www.tvlicensing.biz/]