Copy a paragraph style from template to document

J

Jacqui

I am trying to write a macro which will copy a particular paragraph
style from my normal.dot to the active document. I've trawled through
the posts but can only find one which copies all styles, which I don't
particularly want to do. Can anyone help?

thanks
 
R

Russ

Jacqui,

Record a macro while using the Word Organizer to do what you want and the
relevant code will look something like this:

Application.OrganizerCopy Source:= _
"MyFullPathToOfficeStuff\Microsoft User Data\Normal",
Destination:=ActiveDocument.FullName _
, Name:= _
"MyStyle", Object:=wdOrganizerObjectStyles
 
J

Jacqui

Jacqui,

Record a macro while using the Word Organizer to do what you want and the
relevant code will look something like this:

Application.OrganizerCopy Source:= _
"MyFullPathToOfficeStuff\Microsoft User Data\Normal",
Destination:=ActiveDocument.FullName _
, Name:= _
"MyStyle", Object:=wdOrganizerObjectStyles
Thanks for coming back to me Russ -

I tried that and here's the code I got:
Sub CopyDefinitionPara()
'
' CopyDefinitionPara Macro
' Macro recorded 14/08/2007 by Jacqueline Fulton
'
With ActiveDocument
.UpdateStylesOnOpen = False
.AttachedTemplate = "Normal"
End With
Application.OrganizerCopy Source:="C:\template\normal.dot",
Destination:= _
"F:\JF\Documents to be reformatted\Shop lease -
precedent.doc", Name:= _
"Definition Para", Object:=wdOrganizerObjectStyles
End Sub

This copies the style to this particular document but I want to be
able to run it in any document and the style is copied to the Active
Document - so I want to replace the destination doc name bit with
whatever I need for Active document (tried changing it to
ActiveDocument - but that didn't work either)
 
S

Stefan Blom

Have you tried using Destination:=ActiveDocument.Name ?

--
Stefan Blom
Microsoft Word MVP


in message
 
J

Jacqui

Have you tried using Destination:=ActiveDocument.Name ?

--
Stefan Blom
Microsoft Word MVP

in message







- Show quoted text -

Yes I tried that also. I did again when I saw your message and here's
my code
ub CopyDefinitionPara()
'
' CopyDefinitionPara Macro
' Macro recorded 14/08/2007 by Jacqueline Fulton
'
With ActiveDocument
.UpdateStylesOnOpen = False
.AttachedTemplate = "Normal"
End With
Application.OrganizerCopy Source:="C:\template\normal.dot",
Destination:=ActiveDocument.Name, Name:= _
"Definition Para", Object:=wdOrganizerObjectStyles
End Sub

It still doesn't work - this is driving me nuts!
 
S

Stefan Blom

What happens when you try? Is there an error message? Does it work if you
try Destination:=ActiveDocument.FullName instead?

--
Stefan Blom
Microsoft Word MVP


in message
 
J

Jacqui

What happens when you try? Is there an error message? Does it work if you
try Destination:=ActiveDocument.FullName instead?

--
Stefan Blom
Microsoft Word MVP

in message







- Show quoted text -

Just tried it with Full.Name and it worked! Thanks Stefan
 
R

Russ

Jacqui,
Sorry it took you so long to figure this out, but if you had looked at my
original message more closely, you would have noticed that I had substituted
ActiveDocument.FullName in the code. I should have mentioned that, but I was
I trying to get out a quick message. I didn't test it, but it made sense
because the original code had the full path.
 

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