A
Alex St-Pierre
Hi,
I have an excel macro that open a word document and add text at the left of
the footer (with left alignment). Does anyone know how can I add the page
number at the right of the footer (with right alignment) ? I don't know how
to add 2 differents texts with differents alignments in the same footer.
The actual macro is the following:
Sub Word_Footer()
Dim WdApp As Object 'Word.Application
Dim myDoc As Object 'Document
Dim SourceFileI As String
Dim DestinationFileI As String
On Error Resume Next
Set WdApp = GetObject("", "Word.Application")
If WdApp Is Nothing Then
Set WdApp = CreateObject("Word.Application")
End If
On Error GoTo 0
WdApp.Visible = True
SourceFileI = "C:\SourceFile.doc"
DestinationFileI = "C:\DestinationFile.doc"
FileCopy SourceFileI, DestinationFileI
Set myDoc = WdApp.Documents.Open(Filename:=DestinationFileI)
myDoc.sections(1).footers(1).Range.Text = Nom
myDoc.sections(1).footers(1).Range.Select
myDoc.sections(1).footers(1).Range.Font.Bold = False
myDoc.sections(1).footers(1).Range.Font.Name = "Arial"
myDoc.sections(1).footers(1).Range.Font.Size = 10
myDoc.sections(1).footers(1).Range.ParagraphFormat.Alignment = 0
myDoc.Save
myDoc.Close
Set myDoc = Nothing
Set WdApp = Nothing
End Sub()
Thank you !
I have an excel macro that open a word document and add text at the left of
the footer (with left alignment). Does anyone know how can I add the page
number at the right of the footer (with right alignment) ? I don't know how
to add 2 differents texts with differents alignments in the same footer.
The actual macro is the following:
Sub Word_Footer()
Dim WdApp As Object 'Word.Application
Dim myDoc As Object 'Document
Dim SourceFileI As String
Dim DestinationFileI As String
On Error Resume Next
Set WdApp = GetObject("", "Word.Application")
If WdApp Is Nothing Then
Set WdApp = CreateObject("Word.Application")
End If
On Error GoTo 0
WdApp.Visible = True
SourceFileI = "C:\SourceFile.doc"
DestinationFileI = "C:\DestinationFile.doc"
FileCopy SourceFileI, DestinationFileI
Set myDoc = WdApp.Documents.Open(Filename:=DestinationFileI)
myDoc.sections(1).footers(1).Range.Text = Nom
myDoc.sections(1).footers(1).Range.Select
myDoc.sections(1).footers(1).Range.Font.Bold = False
myDoc.sections(1).footers(1).Range.Font.Name = "Arial"
myDoc.sections(1).footers(1).Range.Font.Size = 10
myDoc.sections(1).footers(1).Range.ParagraphFormat.Alignment = 0
myDoc.Save
myDoc.Close
Set myDoc = Nothing
Set WdApp = Nothing
End Sub()
Thank you !