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
|
|||
|
|||
Word 2007 - put footer onto every new document when Word starts
Hi,
I've tried to find the solution to this, but to no avail. In 2003 we modified the normal.dot so that every new document had the filename and path in the footer. In 2007 I have modified the normal.dotm and if I click the Office Button, New, my templates, Normal then it works fine, but what I want is when the user just opens Word that the footer already contains the footer. I've got to roll this to 150 users so didn't want to modify each machine, but can make changes in Group Policy or via the login script (to copy files into locations, etc). Any help is gratefully received |
#2
|
|||
|
|||
Word 2007 - put footer onto every new document when Word starts
It is not a good idea to have a footer in the normal template. For a start
it prevents you from creating labels. Furthermore the filename field does not update automatically and the document will not have a filename until the document is saved. It would be better either to create a document template containing the footer, which you can distribute via a shared workgroup folder, or copy to the user's User Templates folder. OR My preferred method would be to use a macro to insert and update the filename field in the footer. The following macro will insert the filename and path in each footer of each section of the document after any existing footer content. It will only insert the field once, and just updates the field if already present. Sub InsertFilenameInFooter() Dim oSection As Section Dim ofooter As HeaderFooter Dim oRng As Range Dim oFld As Field ActiveDocument.Save For Each oSection In ActiveDocument.Sections For Each ofooter In oSection.Footers Set oRng = ofooter.Range With oRng For Each oFld In oRng.Fields If oFld.Type = wdFieldFileName Then oFld.Update Exit Sub End If Next oFld If Len(oRng) 1 Then .InsertAfter vbCr End If .Start = ofooter.Range.End .End = ofooter.Range.End .Fields.Add oRng, wdFieldFileName, "\p", False .ParagraphFormat.Alignment = wdAlignParagraphRight .Font.Size = 8 .Fields.Update End With Next ofooter Next oSection End Sub http://www.gmayor.com/installing_macro.htm You could supply this macro in an add-in with a modified ribbon containing a button command to run it - http://gregmaxey.mvps.org/Customize_Ribbon.htm -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org "Tony Harrison" wrote in message ... Hi, I've tried to find the solution to this, but to no avail. In 2003 we modified the normal.dot so that every new document had the filename and path in the footer. In 2007 I have modified the normal.dotm and if I click the Office Button, New, my templates, Normal then it works fine, but what I want is when the user just opens Word that the footer already contains the footer. I've got to roll this to 150 users so didn't want to modify each machine, but can make changes in Group Policy or via the login script (to copy files into locations, etc). Any help is gratefully received |
#3
|
|||
|
|||
Word 2007 - put footer onto every new document when Word start
Thanks for the quick reply Graham.
I'm going to have to learn some commands here because for me, running your macro simply saves the document. Nothing appears in word 2007 documents, and certainly nothing in the footer stage. Obviously something with my set up or something. I'll step it through the debugger and see if I can see why mine is not working. BTW I went with option 2 - get a macro to do the hard work. tony "Graham Mayor" wrote: It is not a good idea to have a footer in the normal template. For a start it prevents you from creating labels. Furthermore the filename field does not update automatically and the document will not have a filename until the document is saved. It would be better either to create a document template containing the footer, which you can distribute via a shared workgroup folder, or copy to the user's User Templates folder. OR My preferred method would be to use a macro to insert and update the filename field in the footer. The following macro will insert the filename and path in each footer of each section of the document after any existing footer content. It will only insert the field once, and just updates the field if already present. Sub InsertFilenameInFooter() Dim oSection As Section Dim ofooter As HeaderFooter Dim oRng As Range Dim oFld As Field ActiveDocument.Save For Each oSection In ActiveDocument.Sections For Each ofooter In oSection.Footers Set oRng = ofooter.Range With oRng For Each oFld In oRng.Fields If oFld.Type = wdFieldFileName Then oFld.Update Exit Sub End If Next oFld If Len(oRng) 1 Then .InsertAfter vbCr End If .Start = ofooter.Range.End .End = ofooter.Range.End .Fields.Add oRng, wdFieldFileName, "\p", False .ParagraphFormat.Alignment = wdAlignParagraphRight .Font.Size = 8 .Fields.Update End With Next ofooter Next oSection End Sub http://www.gmayor.com/installing_macro.htm You could supply this macro in an add-in with a modified ribbon containing a button command to run it - http://gregmaxey.mvps.org/Customize_Ribbon.htm -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org "Tony Harrison" wrote in message ... Hi, I've tried to find the solution to this, but to no avail. In 2003 we modified the normal.dot so that every new document had the filename and path in the footer. In 2007 I have modified the normal.dotm and if I click the Office Button, New, my templates, Normal then it works fine, but what I want is when the user just opens Word that the footer already contains the footer. I've got to roll this to 150 users so didn't want to modify each machine, but can make changes in Group Policy or via the login script (to copy files into locations, etc). Any help is gratefully received . |
#4
|
|||
|
|||
Word 2007 - put footer onto every new document when Word start
I have just copied the code from the reply to Word 2007 and apart from
showing the field code rather than the result it saves the document and puts the saved name and path in the footer in 8 point font. Do you have enough footer space to insert it? To fix the code display issue add the line ActiveWindow.View.ShowFieldCodes = False before End Sub. -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org "Tony Harrison" wrote in message ... Thanks for the quick reply Graham. I'm going to have to learn some commands here because for me, running your macro simply saves the document. Nothing appears in word 2007 documents, and certainly nothing in the footer stage. Obviously something with my set up or something. I'll step it through the debugger and see if I can see why mine is not working. BTW I went with option 2 - get a macro to do the hard work. tony "Graham Mayor" wrote: It is not a good idea to have a footer in the normal template. For a start it prevents you from creating labels. Furthermore the filename field does not update automatically and the document will not have a filename until the document is saved. It would be better either to create a document template containing the footer, which you can distribute via a shared workgroup folder, or copy to the user's User Templates folder. OR My preferred method would be to use a macro to insert and update the filename field in the footer. The following macro will insert the filename and path in each footer of each section of the document after any existing footer content. It will only insert the field once, and just updates the field if already present. Sub InsertFilenameInFooter() Dim oSection As Section Dim ofooter As HeaderFooter Dim oRng As Range Dim oFld As Field ActiveDocument.Save For Each oSection In ActiveDocument.Sections For Each ofooter In oSection.Footers Set oRng = ofooter.Range With oRng For Each oFld In oRng.Fields If oFld.Type = wdFieldFileName Then oFld.Update Exit Sub End If Next oFld If Len(oRng) 1 Then .InsertAfter vbCr End If .Start = ofooter.Range.End .End = ofooter.Range.End .Fields.Add oRng, wdFieldFileName, "\p", False .ParagraphFormat.Alignment = wdAlignParagraphRight .Font.Size = 8 .Fields.Update End With Next ofooter Next oSection End Sub http://www.gmayor.com/installing_macro.htm You could supply this macro in an add-in with a modified ribbon containing a button command to run it - http://gregmaxey.mvps.org/Customize_Ribbon.htm -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org "Tony Harrison" wrote in message ... Hi, I've tried to find the solution to this, but to no avail. In 2003 we modified the normal.dot so that every new document had the filename and path in the footer. In 2007 I have modified the normal.dotm and if I click the Office Button, New, my templates, Normal then it works fine, but what I want is when the user just opens Word that the footer already contains the footer. I've got to roll this to 150 users so didn't want to modify each machine, but can make changes in Group Policy or via the login script (to copy files into locations, etc). Any help is gratefully received . |
#5
|
|||
|
|||
Word 2007 - put footer onto every new document when Word start
Note that adding the macro to the template won't affect already
existing documents based on that template, but only new documents created from it. On Jun 1, 1:47*am, "Graham Mayor" wrote: I have just copied the code from the reply to Word 2007 and apart from showing the field code rather than the result it saves the document and puts the saved name and path in the footer in 8 point font. Do you have enough footer space to insert it? To fix the code display issue add the line ActiveWindow.View.ShowFieldCodes = False before End Sub. -- Graham Mayor - *Word MVP My web sitewww.gmayor.com Word MVP web sitehttp://word.mvps.org "Tony Harrison" wrote in message ... Thanks for the quick reply Graham. I'm going to have to learn some commands here because for me, running your macro simply saves the document. Nothing appears in word 2007 documents, and certainly nothing in the footer stage. Obviously something with my set up or something. I'll step it through the debugger and see if I can see why mine is not working. BTW I went with option 2 - get a macro to do the hard work. tony "Graham Mayor" wrote: It is not a good idea to have a footer in the normal template. For a start it prevents you from creating labels. Furthermore the filename field does not update automatically and the document will not have a filename until the document is saved. It would be better either to create a document template containing the footer, which you can distribute via a shared workgroup folder, or copy to the user's User Templates folder. OR My preferred method would be to use a macro to insert and update the filename field in the footer. The following macro will insert the filename and path in each footer of each section of the document after any existing footer content. It will only insert the field once, and just updates the field if already present. Sub InsertFilenameInFooter() Dim oSection As Section Dim ofooter As HeaderFooter Dim oRng As Range Dim oFld As Field ActiveDocument.Save For Each oSection In ActiveDocument.Sections * * For Each ofooter In oSection.Footers * * * * Set oRng = ofooter.Range * * * * With oRng * * * * * * For Each oFld In oRng.Fields * * * * * * * * If oFld.Type = wdFieldFileName Then * * * * * * * * * * oFld.Update * * * * * * * * * * Exit Sub * * * * * * * * End If * * * * * * Next oFld * * * * * * If Len(oRng) 1 Then * * * * * * * * .InsertAfter vbCr * * * * * * End If * * * * * * .Start = ofooter.Range.End * * * * * * .End = ofooter.Range.End * * * * * * .Fields.Add oRng, wdFieldFileName, "\p", False * * * * * * .ParagraphFormat.Alignment = wdAlignParagraphRight * * * * * * .Font.Size = 8 * * * * * * .Fields.Update * * * * End With * * Next ofooter Next oSection End Sub http://www.gmayor.com/installing_macro.htm You could supply this macro in an add-in with a modified ribbon containing a button command to run it -http://gregmaxey.mvps.org/Customize_Ribbon.htm -- Graham Mayor - *Word MVP My web sitewww.gmayor.com Word MVP web sitehttp://word.mvps.org "Tony Harrison" wrote in message ... Hi, I've tried to find the solution to this, but to no avail. In 2003 we modified the normal.dot so that every new document had the filename and path in the footer. In 2007 I have modified the normal.dotm and if I click the Office Button, New, my templates, Normal then it works fine, but what I want is when the user just opens Word that the footer already contains the footer. I've got to roll this to 150 users so didn't want to modify each machine, but can make changes in Group Policy or via the login script (to copy files into locations, etc). Any help is gratefully received |
#6
|
|||
|
|||
Word 2007 - put footer onto every new document when Word start
That's the trick Graham - thanks. If I open (to view) the footer the code is
there. Thanks for the help. tony "Graham Mayor" wrote: I have just copied the code from the reply to Word 2007 and apart from showing the field code rather than the result it saves the document and puts the saved name and path in the footer in 8 point font. Do you have enough footer space to insert it? To fix the code display issue add the line ActiveWindow.View.ShowFieldCodes = False before End Sub. -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org "Tony Harrison" wrote in message ... Thanks for the quick reply Graham. I'm going to have to learn some commands here because for me, running your macro simply saves the document. Nothing appears in word 2007 documents, and certainly nothing in the footer stage. Obviously something with my set up or something. I'll step it through the debugger and see if I can see why mine is not working. BTW I went with option 2 - get a macro to do the hard work. tony "Graham Mayor" wrote: It is not a good idea to have a footer in the normal template. For a start it prevents you from creating labels. Furthermore the filename field does not update automatically and the document will not have a filename until the document is saved. It would be better either to create a document template containing the footer, which you can distribute via a shared workgroup folder, or copy to the user's User Templates folder. OR My preferred method would be to use a macro to insert and update the filename field in the footer. The following macro will insert the filename and path in each footer of each section of the document after any existing footer content. It will only insert the field once, and just updates the field if already present. Sub InsertFilenameInFooter() Dim oSection As Section Dim ofooter As HeaderFooter Dim oRng As Range Dim oFld As Field ActiveDocument.Save For Each oSection In ActiveDocument.Sections For Each ofooter In oSection.Footers Set oRng = ofooter.Range With oRng For Each oFld In oRng.Fields If oFld.Type = wdFieldFileName Then oFld.Update Exit Sub End If Next oFld If Len(oRng) 1 Then .InsertAfter vbCr End If .Start = ofooter.Range.End .End = ofooter.Range.End .Fields.Add oRng, wdFieldFileName, "\p", False .ParagraphFormat.Alignment = wdAlignParagraphRight .Font.Size = 8 .Fields.Update End With Next ofooter Next oSection End Sub http://www.gmayor.com/installing_macro.htm You could supply this macro in an add-in with a modified ribbon containing a button command to run it - http://gregmaxey.mvps.org/Customize_Ribbon.htm -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org "Tony Harrison" wrote in message ... Hi, I've tried to find the solution to this, but to no avail. In 2003 we modified the normal.dot so that every new document had the filename and path in the footer. In 2007 I have modified the normal.dotm and if I click the Office Button, New, my templates, Normal then it works fine, but what I want is when the user just opens Word that the footer already contains the footer. I've got to roll this to 150 users so didn't want to modify each machine, but can make changes in Group Policy or via the login script (to copy files into locations, etc). Any help is gratefully received . . |
#7
|
|||
|
|||
Word 2007 - put footer onto every new document when Word start
Does it show in print preview?
-- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org "Tony Harrison" wrote in message ... That's the trick Graham - thanks. If I open (to view) the footer the code is there. Thanks for the help. tony "Graham Mayor" wrote: I have just copied the code from the reply to Word 2007 and apart from showing the field code rather than the result it saves the document and puts the saved name and path in the footer in 8 point font. Do you have enough footer space to insert it? To fix the code display issue add the line ActiveWindow.View.ShowFieldCodes = False before End Sub. -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org "Tony Harrison" wrote in message ... Thanks for the quick reply Graham. I'm going to have to learn some commands here because for me, running your macro simply saves the document. Nothing appears in word 2007 documents, and certainly nothing in the footer stage. Obviously something with my set up or something. I'll step it through the debugger and see if I can see why mine is not working. BTW I went with option 2 - get a macro to do the hard work. tony "Graham Mayor" wrote: It is not a good idea to have a footer in the normal template. For a start it prevents you from creating labels. Furthermore the filename field does not update automatically and the document will not have a filename until the document is saved. It would be better either to create a document template containing the footer, which you can distribute via a shared workgroup folder, or copy to the user's User Templates folder. OR My preferred method would be to use a macro to insert and update the filename field in the footer. The following macro will insert the filename and path in each footer of each section of the document after any existing footer content. It will only insert the field once, and just updates the field if already present. Sub InsertFilenameInFooter() Dim oSection As Section Dim ofooter As HeaderFooter Dim oRng As Range Dim oFld As Field ActiveDocument.Save For Each oSection In ActiveDocument.Sections For Each ofooter In oSection.Footers Set oRng = ofooter.Range With oRng For Each oFld In oRng.Fields If oFld.Type = wdFieldFileName Then oFld.Update Exit Sub End If Next oFld If Len(oRng) 1 Then .InsertAfter vbCr End If .Start = ofooter.Range.End .End = ofooter.Range.End .Fields.Add oRng, wdFieldFileName, "\p", False .ParagraphFormat.Alignment = wdAlignParagraphRight .Font.Size = 8 .Fields.Update End With Next ofooter Next oSection End Sub http://www.gmayor.com/installing_macro.htm You could supply this macro in an add-in with a modified ribbon containing a button command to run it - http://gregmaxey.mvps.org/Customize_Ribbon.htm -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org "Tony Harrison" wrote in message ... Hi, I've tried to find the solution to this, but to no avail. In 2003 we modified the normal.dot so that every new document had the filename and path in the footer. In 2007 I have modified the normal.dotm and if I click the Office Button, New, my templates, Normal then it works fine, but what I want is when the user just opens Word that the footer already contains the footer. I've got to roll this to 150 users so didn't want to modify each machine, but can make changes in Group Policy or via the login script (to copy files into locations, etc). Any help is gratefully received . . |
#8
|
|||
|
|||
Word 2007 - put footer onto every new document when Word start
Yes it does. Just not in my default view which is Print Layout.
"Graham Mayor" wrote: Does it show in print preview? -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org "Tony Harrison" wrote in message ... That's the trick Graham - thanks. If I open (to view) the footer the code is there. Thanks for the help. tony "Graham Mayor" wrote: I have just copied the code from the reply to Word 2007 and apart from showing the field code rather than the result it saves the document and puts the saved name and path in the footer in 8 point font. Do you have enough footer space to insert it? To fix the code display issue add the line ActiveWindow.View.ShowFieldCodes = False before End Sub. -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org "Tony Harrison" wrote in message ... Thanks for the quick reply Graham. I'm going to have to learn some commands here because for me, running your macro simply saves the document. Nothing appears in word 2007 documents, and certainly nothing in the footer stage. Obviously something with my set up or something. I'll step it through the debugger and see if I can see why mine is not working. BTW I went with option 2 - get a macro to do the hard work. tony "Graham Mayor" wrote: It is not a good idea to have a footer in the normal template. For a start it prevents you from creating labels. Furthermore the filename field does not update automatically and the document will not have a filename until the document is saved. It would be better either to create a document template containing the footer, which you can distribute via a shared workgroup folder, or copy to the user's User Templates folder. OR My preferred method would be to use a macro to insert and update the filename field in the footer. The following macro will insert the filename and path in each footer of each section of the document after any existing footer content. It will only insert the field once, and just updates the field if already present. Sub InsertFilenameInFooter() Dim oSection As Section Dim ofooter As HeaderFooter Dim oRng As Range Dim oFld As Field ActiveDocument.Save For Each oSection In ActiveDocument.Sections For Each ofooter In oSection.Footers Set oRng = ofooter.Range With oRng For Each oFld In oRng.Fields If oFld.Type = wdFieldFileName Then oFld.Update Exit Sub End If Next oFld If Len(oRng) 1 Then .InsertAfter vbCr End If .Start = ofooter.Range.End .End = ofooter.Range.End .Fields.Add oRng, wdFieldFileName, "\p", False .ParagraphFormat.Alignment = wdAlignParagraphRight .Font.Size = 8 .Fields.Update End With Next ofooter Next oSection End Sub http://www.gmayor.com/installing_macro.htm You could supply this macro in an add-in with a modified ribbon containing a button command to run it - http://gregmaxey.mvps.org/Customize_Ribbon.htm -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org "Tony Harrison" wrote in message ... Hi, I've tried to find the solution to this, but to no avail. In 2003 we modified the normal.dot so that every new document had the filename and path in the footer. In 2007 I have modified the normal.dotm and if I click the Office Button, New, my templates, Normal then it works fine, but what I want is when the user just opens Word that the footer already contains the footer. I've got to roll this to 150 users so didn't want to modify each machine, but can make changes in Group Policy or via the login script (to copy files into locations, etc). Any help is gratefully received . . . |
#9
|
|||
|
|||
Word 2007 - put footer onto every new document when Word start
In that case it is a display issue not attributable to the macro. I am not
sure what to suggest to resolve that. -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org "Tony Harrison" wrote in message ... Yes it does. Just not in my default view which is Print Layout. "Graham Mayor" wrote: Does it show in print preview? -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org "Tony Harrison" wrote in message ... That's the trick Graham - thanks. If I open (to view) the footer the code is there. Thanks for the help. tony "Graham Mayor" wrote: I have just copied the code from the reply to Word 2007 and apart from showing the field code rather than the result it saves the document and puts the saved name and path in the footer in 8 point font. Do you have enough footer space to insert it? To fix the code display issue add the line ActiveWindow.View.ShowFieldCodes = False before End Sub. -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org "Tony Harrison" wrote in message ... Thanks for the quick reply Graham. I'm going to have to learn some commands here because for me, running your macro simply saves the document. Nothing appears in word 2007 documents, and certainly nothing in the footer stage. Obviously something with my set up or something. I'll step it through the debugger and see if I can see why mine is not working. BTW I went with option 2 - get a macro to do the hard work. tony "Graham Mayor" wrote: It is not a good idea to have a footer in the normal template. For a start it prevents you from creating labels. Furthermore the filename field does not update automatically and the document will not have a filename until the document is saved. It would be better either to create a document template containing the footer, which you can distribute via a shared workgroup folder, or copy to the user's User Templates folder. OR My preferred method would be to use a macro to insert and update the filename field in the footer. The following macro will insert the filename and path in each footer of each section of the document after any existing footer content. It will only insert the field once, and just updates the field if already present. Sub InsertFilenameInFooter() Dim oSection As Section Dim ofooter As HeaderFooter Dim oRng As Range Dim oFld As Field ActiveDocument.Save For Each oSection In ActiveDocument.Sections For Each ofooter In oSection.Footers Set oRng = ofooter.Range With oRng For Each oFld In oRng.Fields If oFld.Type = wdFieldFileName Then oFld.Update Exit Sub End If Next oFld If Len(oRng) 1 Then .InsertAfter vbCr End If .Start = ofooter.Range.End .End = ofooter.Range.End .Fields.Add oRng, wdFieldFileName, "\p", False .ParagraphFormat.Alignment = wdAlignParagraphRight .Font.Size = 8 .Fields.Update End With Next ofooter Next oSection End Sub http://www.gmayor.com/installing_macro.htm You could supply this macro in an add-in with a modified ribbon containing a button command to run it - http://gregmaxey.mvps.org/Customize_Ribbon.htm -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org "Tony Harrison" wrote in message ... Hi, I've tried to find the solution to this, but to no avail. In 2003 we modified the normal.dot so that every new document had the filename and path in the footer. In 2007 I have modified the normal.dotm and if I click the Office Button, New, my templates, Normal then it works fine, but what I want is when the user just opens Word that the footer already contains the footer. I've got to roll this to 150 users so didn't want to modify each machine, but can make changes in Group Policy or via the login script (to copy files into locations, etc). Any help is gratefully received . . . |
Thread Tools | |
Display Modes | |
|
|