filelocations in worddocument

N

NeCrite.nl

Okay,

I know how to get the { Filename \p } in the footer and how to update
it manually.
I want a .dot file, which will be saved as normal.dot for all users
here to use it.
But what I want is that after I put in that line it automatically
updates the filelocation with path after I save or after it could be
changed.

Cause from what I can see now is that it doesn't automatically updates
the filename and I have to press F9 or Alt-F9 in Word 2003.

How can I do this or some advice please.

Best regards,

René Klomp
 
N

NeCrite.nl

I am going to try this later today, thank you for your response.

Does anyone know a simple way to put aa file location footer in
existing documents?

Best regards,

René
 
G

Graham Mayor

If you mean insert into the currently open document then

Sub InsertFilenameFooter()
With ActiveDocument
If Len(.Path) = 0 Then
.Save
End If
End With
Selection.EndKey Unit:=wdStory
ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageFooter
Selection.Fields.Add Range:=Selection.Range, _
Type:=wdFieldFileName, Text:="\p", _
PreserveFormatting:=False
With ActiveWindow.ActivePane.View
.SeekView = wdSeekMainDocument
End With
End Sub


--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
N

NeCrite.nl

Hehe what I mean is that there are like thousands of files that don't
have the filename in the document.
Is there a quick way to get the filename in the footer for all...

Maybe I am too hopefull
 
G

Graham Mayor

Use the following instead - however I would test on copies of the files.

Sub BatchAddFilename()
Dim myFile As String
Dim PathToUse As String
Dim MyDoc As Document
Dim iFld As Integer

With Dialogs(wdDialogCopyFile)
If .Display <> 0 Then
PathToUse = .Directory
Else
MsgBox "Cancelled by User"
Exit Sub
End If
End With
If Documents.Count > 0 Then
Documents.Close SaveChanges:=wdPromptToSaveChanges
End If
If Left(PathToUse, 1) = Chr(34) Then
PathToUse = Mid(PathToUse, 2, Len(PathToUse) - 2)
End If
myFile = Dir$(PathToUse & "*.do?")
While myFile <> ""
Set MyDoc = Documents.Open(PathToUse & myFile)
Selection.EndKey Unit:=wdStory
ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageFooter
Selection.EndKey Unit:=wdStory
Selection.Fields.Add Range:=Selection.Range, _
Type:=wdFieldFileName, Text:="\p", _
PreserveFormatting:=False
With ActiveWindow.ActivePane.View
.SeekView = wdSeekMainDocument
End With
MyDoc.Close SaveChanges:=wdSaveChanges
myFile = Dir$()
Wend
End Sub


--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
S

Suzanne S. Barnhill

See
How to Find & ReplaceAll on a Batch of Documents in the Same Folder
http://word.mvps.org/FAQs/MacrosVBA/BatchFR.htm

Replace text on a batch of files
http://www.gmayor.com/batch_replace.htm
http://gregmaxey.mvps.org/VBA_Find_And_Replace.htm

One or more of these articles should give you a starting point for inserting
text in a batch of documents.

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA

Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.
 
N

NeCrite.nl

In the script of Graham, how do I let it place an enter before
importing the file location in the document?

Thanks
 
G

Graham Mayor

In the script of Graham, how do I let it place an enter before
importing the file location in the document?

Thanks

Locate the following part

ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageFooter
Selection.EndKey Unit:=wdStory
Selection.Fields.Add Range:=Selection.Range, _
Type:=wdFieldFileName, Text:="\p", _
PreserveFormatting:=False


And replace it with

ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageFooter
With Selection
.EndKey Unit:=wdStory
.TypeParagraph 'adds the 'enter'
'Optional additional formatting examples
'************************************
.ParagraphFormat.Alignment = wdAlignParagraphRight
.Font.Name = "Arial"
.Font.Size = "8"
.Font.Italic = True
'************************************
.Fields.Add Range:=Selection.Range, _
Type:=wdFieldFileName, Text:="\p", _
PreserveFormatting:=False
End With



--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top