Hi Shim,
you may
put an inklusive bookmark in the header,
preferebly in the header of a template,
which looks like [Foldername], and call it "Folderheader".
And
put an inklusive bookmark in the footer,
preferebly in the footer of a template,
which looks like [Foldername], and call it "FolderFooter".
And
put several REF-Fields in the doc's mainstory,
which look like { REF FolderHeader }.
And try:
Sub InsertFolderName()
Dim strF As String ' the folder name
Dim rngT As Range ' a temporary range
' get name of folder
' hard for a beginner, though
strF = ActiveDocument.FullName
strF = StrReverse(strF)
strF = Right(strF, Len(strF) - InStr(strF, "\"))
strF = Left(strF, InStr(strF, "\") - 1)
strF = StrReverse(strF)
With ActiveDocument.Bookmarks
.Item ("FolderHeader")
Set rngT = .Item("FolderHeader").Range
rngT.Text = strF
.Add Name:="FolderHeader", Range:=rngT
.Item ("FolderFooter")
Set rngT = .Item("FolderFooter").Range
rngT.Text = strF
.Add Name:="FolderFooter", Range:=rngT
End With
ActiveDocument.Fields.Update
End Sub
Put sub InsertFolderName in Normal.dot.
Try to work your way through "Tools, Customize".
From then on it's not a matter of programming anymore.
Lots of other solutions possible.
Greetings from Bavaria, Germany
Helmut Weber, MVP WordVBA
Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"