Insert footer

Rakesh935

Registered User.
Local time
Tomorrow, 02:53
Joined
Oct 14, 2012
Messages
71
Hi,

I have been writing few codes in order to add a footer in a word doc through access vba and I also referred few of the threads but unfortunately nothing worked out.

Requesting, if anybody could help me with this regard.

Thank you,
Rakesh
 
I think nobody would be able to revert if you do not elaborate what you tried and how it did not work!!
 
Hi there,

Thanks for the revert.

Well I am creating a tool in access vba, where in browse and selecting multiple word file only and getting them updated with the footer.

Below is the code for the same.....

Dim word As word.Application
Dim document As word.document
Dim wrdSelection As word.Selection
Dim strDocPath As String
Dim fDialog As FileDialog
' Set up the File Dialog. '
Set fDialog = Application.FileDialog(msoFileDialogFilePicker)
Dim varFile As Variant
With fDialog
.AllowMultiSelect = True
.Title = "Select File Location to Export docx :"
.InitialFileName = ""
If .Show = True Then
For Each varFile In .SelectedItems
GetFileName = varFile
strDocPath = GetFileName
Set word = CreateObject("Word.Application")
word.Visible = True
word.Documents.Open (strDocPath)




With ActiveDocument.Sections(1)
.Headers(wdHeaderFooterPrimary).Range.Text = "Header text"
.Footers(wdHeaderFooterPrimary).Range.Text = "Footer text"
End With










ActiveDocument.Save
ActiveDocument.Close
Set word = Nothing
Set doc = Nothing
Set wrdSelection = Nothing
Next
End If
End With
Set word = Nothing
Set document = Nothing
MsgBox "Updated Successfully"


And i get error in the code...

With ActiveDocument.Sections(1)
.Headers(wdHeaderFooterPrimary).Range.Text = "Header text"
.Footers(wdHeaderFooterPrimary).Range.Text = "Footer text"
End With


Requesting if could help me.

Thanks,
Rakesh
 
Hey guys,

I finally found the solutions for the problem and hope it help others in future....

Below is the code.....

Dim word As word.Application
Dim document As word.document
Dim wrdSelection As word.Selection
Dim strDocPath As String
Dim fDialog As FileDialog
' Set up the File Dialog. '
Set fDialog = Application.FileDialog(msoFileDialogFilePicker)
Dim varFile As Variant
With fDialog
.AllowMultiSelect = True
.Title = "Select File Location to Export docx :"
.InitialFileName = ""
If .Show = True Then
For Each varFile In .SelectedItems
GetFileName = varFile
strDocPath = GetFileName
Set word = CreateObject("Word.Application")
word.Visible = True
word.Documents.Open (strDocPath)
Set document = word.Documents(1)
With document.Sections(1)
.Footers(wdHeaderFooterPrimary).Range.Text = "SAP Internal"
End With
word.ActiveDocument.Save
word.ActiveDocument.Close
word.Quit
Set word = Nothing
Set doc = Nothing
Set wrdSelection = Nothing
Next
End If
End With
Set word = Nothing
Set document = Nothing
MsgBox "Updated Successfully"



Thanks
Rakesh
 

Users who are viewing this thread

Back
Top Bottom