Stoo85
11-06-2007, 07:56 AM
Hi there,
I have a problem I am hoping someone can help me with.
I am trying to find a method to add in a persons's domain username to the bottom of every Word document.
So far I have got the code to actually add the text in and I can use the "Auto???" macro names to get it to put the inforamtion when Word opens, a use opens a new document or opens an existing document the problem is that I can't stop it putting in if it already exists.
I had thought about just re-setting the footer every time but that won't work as I don't want to delete anything that people have put in the footer.
I would assume I would need something allong the lines of
[IF DOCUMENT FOOTER CONTAINS] environ("username")
[THEN] do nothing
[ELSE] WordBasic.ViewFooterOnly
Selection.TypeText Text:=Environ("username")
Selection.MoveLeft Unit:=wdWord, Count:=1, Extend:=wdExtend
Selection.Font.Color = -603923969
Selection.Font.Size = 10
ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
[END IF]
It's just the syntax of the bits in bold I can't work out. What's anoying is that I can do this easilly in Access VBA. Word just confuses me! :(
Any help would be appreciated.
I have a problem I am hoping someone can help me with.
I am trying to find a method to add in a persons's domain username to the bottom of every Word document.
So far I have got the code to actually add the text in and I can use the "Auto???" macro names to get it to put the inforamtion when Word opens, a use opens a new document or opens an existing document the problem is that I can't stop it putting in if it already exists.
I had thought about just re-setting the footer every time but that won't work as I don't want to delete anything that people have put in the footer.
I would assume I would need something allong the lines of
[IF DOCUMENT FOOTER CONTAINS] environ("username")
[THEN] do nothing
[ELSE] WordBasic.ViewFooterOnly
Selection.TypeText Text:=Environ("username")
Selection.MoveLeft Unit:=wdWord, Count:=1, Extend:=wdExtend
Selection.Font.Color = -603923969
Selection.Font.Size = 10
ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
[END IF]
It's just the syntax of the bits in bold I can't work out. What's anoying is that I can do this easilly in Access VBA. Word just confuses me! :(
Any help would be appreciated.