S
Staroslav
I am trying to write a macro that copies all existing styles from a given
template to an active document. Can't get it to work because Word requires
that I give a name for each style I want to copy. I know it's doable, just am
having problems figuring out the code for it.
Thanks ahead of time for your help!
Below is what I have, but it doesn't work:
Sub CopyAllStyles()
'
Dim SDoc As Document, strDDoc, strSDoc, nStile As String, Stil As Style, S
As Long
strDDoc = ActiveDocument.FullName
strSDoc = "C:\Documents and Settings\Myself\Application
Data\Microsoft\Templates\MyTemplate.dot"
On Error Resume Next
For S = 1 To SDoc.Styles.Count
nStil = SDoc.Styles(S).NameLocal
Application.OrganizerCopy Source:=strSDoc, Destination:=strDDoc, _
Name:=nStil, Object:=wdOrganizerObjectStyles
Next S
End Sub
template to an active document. Can't get it to work because Word requires
that I give a name for each style I want to copy. I know it's doable, just am
having problems figuring out the code for it.
Thanks ahead of time for your help!
Below is what I have, but it doesn't work:
Sub CopyAllStyles()
'
Dim SDoc As Document, strDDoc, strSDoc, nStile As String, Stil As Style, S
As Long
strDDoc = ActiveDocument.FullName
strSDoc = "C:\Documents and Settings\Myself\Application
Data\Microsoft\Templates\MyTemplate.dot"
On Error Resume Next
For S = 1 To SDoc.Styles.Count
nStil = SDoc.Styles(S).NameLocal
Application.OrganizerCopy Source:=strSDoc, Destination:=strDDoc, _
Name:=nStil, Object:=wdOrganizerObjectStyles
Next S
End Sub