Copy the footer style from Normal.dotm to active document

L

Legal Learning

Here is the code I have. I am getting an error saying that it can't find the
file. The template does live in the profile. The activedocument is there.
Please help! Thanks

With ActiveDocument
.UpdateStylesOnOpen = False
.AttachedTemplate = "Normal.dotm"
End With
Application.OrganizerCopy Source:= _
"C:\Documents and Settings\%username%\Application
Data\Microsoft\Templates\Normal.dotm" _
, Destination:=ActiveDocument.FullName, Name:="Footer", Object:= _
wdOrganizerObjectStyles
 
G

Graham Mayor

The problem seems to be that the path seems to be treated as a literal
string, however unless I am very mich mistaken, 'Footer' is a built-in style
and is not available to be copied in the manner you describe. It certainly
doesn't appear in the Styles Organizer on my version of Word 2007, but is
available in All Styles so when you fix the path issue the macro will still
fail because it cannot find the footer style to copy.

With ActiveDocument
.UpdateStylesOnOpen = True
.AttachedTemplate = "Normal.dotm"
End With

should update the styles in the document to match the attached template, or
you could simply redefign the footer style that you want to use in the
document to match your modified footer style.


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


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
L

Legal Learning

Thanks, Graham.

You are right on the money about the footer style being a built-in style and
is not in the Styles Organizer unless you modify it. I have modified the
footer style in the normal.dotm which makes it available in the Styles
Organizer. It's the file name that it doesn't recognize which is weird.
What am I doing wrong on the path/filename?

Thanks for you help
 
G

Graham Mayor

I don't think you are doing anything 'wrong' - it is simply that the
function reads the path as a literal string, so instead of inserting the
username it looks for a folder in the path called \%username% which doesn't
exist.

Try

Application.OrganizerCopy Source:="C:\Documents and Settings\" &
Application.UserName & "\Application Data\Microsoft\Templates\Normal.dotm" _
, Destination:=ActiveDocument.FullName, _
name:="Footer", Object:= _
wdOrganizerObjectStyles

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


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
L

Legal Learning

Graham,

As usual - you do everything "right". Thank you so very much. It works
wonderfully.
 
G

Graham Mayor

Steady ;)

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


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

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