If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
File location auto text
Hi everyone,
Before I open up each document and do this one at a time I was wondering if there is a way to add the auto text for file location to my documents all at once? I have about 100 documents in the same folder. The process I am planning is to open the document/insert file location into the header or footer/print each document. This is so 10 people have copies and the group can determine which documents will be kept and which ones will go. Thanks, Linda |
#2
|
|||
|
|||
File location auto text
If you have all of the documents in a folder, running a macro containing the
following code will add the path and filename to the primary footer of the first section of the document. Change the C:\test to whereever you have the documents. Dim myFile As String Dim PathToUse As String Dim myDoc As Document Dim myrange As Range PathToUse = "C:\Test\" 'Set the directory and type of file to batch process myFile = Dir$(PathToUse & "*.doc") While myFile "" 'Open document Set myDoc = Documents.Open(PathToUse & myFile) Set myrange = myDoc.Sections(1).Footers(wdHeaderFooterPrimary).R ange myrange.Collapse wdCollapseStart myDoc.Fields.Add myrange, wdFieldEmpty, "Filename \p" myrange.Fields.Update 'Close the modified document after saving changes myDoc.Close SaveChanges:=wdSaveChanges 'Next file in folder myFile = Dir$() Wend See the article "What do I do with macros sent to me by other newsgroup readers to help me out?" at: http://www.word.mvps.org/FAQs/Macros...eateAMacro.htm -- Hope this helps. Please reply to the newsgroup unless you wish to avail yourself of my services on a paid consulting basis. Doug Robbins - Word MVP "Linda RQ" wrote in message ... Hi everyone, Before I open up each document and do this one at a time I was wondering if there is a way to add the auto text for file location to my documents all at once? I have about 100 documents in the same folder. The process I am planning is to open the document/insert file location into the header or footer/print each document. This is so 10 people have copies and the group can determine which documents will be kept and which ones will go. Thanks, Linda |
#3
|
|||
|
|||
File location auto text
Thanks Doug. The documents are on a network drive. Does that require any
additional text? I printed this and the Macro Instructions so when I get to work tomorrow, it will be sitting there ready for me to try it. The "What to do with a Macro" article is a great thing to add to this...I have worked with very few macros and needed to be pulled along each step. Linda "Doug Robbins - Word MVP" wrote in message ... If you have all of the documents in a folder, running a macro containing the following code will add the path and filename to the primary footer of the first section of the document. Change the C:\test to whereever you have the documents. Dim myFile As String Dim PathToUse As String Dim myDoc As Document Dim myrange As Range PathToUse = "C:\Test\" 'Set the directory and type of file to batch process myFile = Dir$(PathToUse & "*.doc") While myFile "" 'Open document Set myDoc = Documents.Open(PathToUse & myFile) Set myrange = myDoc.Sections(1).Footers(wdHeaderFooterPrimary).R ange myrange.Collapse wdCollapseStart myDoc.Fields.Add myrange, wdFieldEmpty, "Filename \p" myrange.Fields.Update 'Close the modified document after saving changes myDoc.Close SaveChanges:=wdSaveChanges 'Next file in folder myFile = Dir$() Wend See the article "What do I do with macros sent to me by other newsgroup readers to help me out?" at: http://www.word.mvps.org/FAQs/Macros...eateAMacro.htm -- Hope this helps. Please reply to the newsgroup unless you wish to avail yourself of my services on a paid consulting basis. Doug Robbins - Word MVP "Linda RQ" wrote in message ... Hi everyone, Before I open up each document and do this one at a time I was wondering if there is a way to add the auto text for file location to my documents all at once? I have about 100 documents in the same folder. The process I am planning is to open the document/insert file location into the header or footer/print each document. This is so 10 people have copies and the group can determine which documents will be kept and which ones will go. Thanks, Linda |
#4
|
|||
|
|||
File location auto text
Only the path to the folder where the files are located. (It would however
be a good idea to try it on a copy of the files in the first instance and for that purpose, you might create a folder called Test on your Crive and then copy the files there.) -- Hope this helps. Please reply to the newsgroup unless you wish to avail yourself of my services on a paid consulting basis. Doug Robbins - Word MVP "Linda RQ" wrote in message ... Thanks Doug. The documents are on a network drive. Does that require any additional text? I printed this and the Macro Instructions so when I get to work tomorrow, it will be sitting there ready for me to try it. The "What to do with a Macro" article is a great thing to add to this...I have worked with very few macros and needed to be pulled along each step. Linda "Doug Robbins - Word MVP" wrote in message ... If you have all of the documents in a folder, running a macro containing the following code will add the path and filename to the primary footer of the first section of the document. Change the C:\test to whereever you have the documents. Dim myFile As String Dim PathToUse As String Dim myDoc As Document Dim myrange As Range PathToUse = "C:\Test\" 'Set the directory and type of file to batch process myFile = Dir$(PathToUse & "*.doc") While myFile "" 'Open document Set myDoc = Documents.Open(PathToUse & myFile) Set myrange = myDoc.Sections(1).Footers(wdHeaderFooterPrimary).R ange myrange.Collapse wdCollapseStart myDoc.Fields.Add myrange, wdFieldEmpty, "Filename \p" myrange.Fields.Update 'Close the modified document after saving changes myDoc.Close SaveChanges:=wdSaveChanges 'Next file in folder myFile = Dir$() Wend See the article "What do I do with macros sent to me by other newsgroup readers to help me out?" at: http://www.word.mvps.org/FAQs/Macros...eateAMacro.htm -- Hope this helps. Please reply to the newsgroup unless you wish to avail yourself of my services on a paid consulting basis. Doug Robbins - Word MVP "Linda RQ" wrote in message ... Hi everyone, Before I open up each document and do this one at a time I was wondering if there is a way to add the auto text for file location to my documents all at once? I have about 100 documents in the same folder. The process I am planning is to open the document/insert file location into the header or footer/print each document. This is so 10 people have copies and the group can determine which documents will be kept and which ones will go. Thanks, Linda |
Thread Tools | |
Display Modes | |
|
|