J
jerem
I am directly formatting paragraphs using Ctrl m (changing indents), Ctrl t
(changing tabbing), Ctrl i, Ctrl b, (font formatting) and Ctrl 1, 2 and 3 for
paragraph after settings, etc., etc. After setting up all the formatting I
create a new style – Cs – which now incorporates all that formatting into the
actual style formatting. I then use the following macro to now make all of
these formatting attributes to be incorporated into a pre-existing style
which has attributes I don't want but which I have to use (company protocol).
[I use the direct formatting because it's faster and easier than navigating
through all the Style settings and you have the visual of what the paragraph
looks like right in front of you]. The code works nicely sometimes and other
times I get a runtime error 4194 and when you go into Debug it is halting on
the OrganizerDelete statement. What I’ve done is copied that statement into
a new macro all by itself. I then create the Cs style and know it is there
in the Organizer (though it may not be in use in the document and maybe this
is what’s creating a problem????), yet when I run this new macro it will not
delete the style from the Organizer. So, in essence I need to have a
statement that will delete Cs in the Organizer regardless of whether the
style is being used in the document. Anybody have a solution. Thanks for
your help.
Sub CopyAttributesOfStyle()
'ShortcutKey = F12
Const Error_StyleDoesNotExist = 5941
Dim t As Style, s As Style
Dim trgStyleName As String
trgStyleName = InputBox("Enter the name of the style to create")
Set s = ActiveDocument.Styles("Cs")
On Error Resume Next
Set t = ActiveDocument.Styles(trgStyleName)
If Err.Number = Error_StyleDoesNotExist Then
MsgBox "The style specified does not exist."
GoTo Done
End If
On Error GoTo 0
With t
.BaseStyle = "Normal"
.ParagraphFormat = s.ParagraphFormat
.Font = s.Font
.LanguageID = s.LanguageID
End With
Selection.Style = trgStyleName
Application.OrganizerDelete Source:=ActiveDocument, Name:="Cs", Object:= _
wdOrganizerObjectStyles
Done:
Set s = Nothing
Set t = Nothing
End Sub
(changing tabbing), Ctrl i, Ctrl b, (font formatting) and Ctrl 1, 2 and 3 for
paragraph after settings, etc., etc. After setting up all the formatting I
create a new style – Cs – which now incorporates all that formatting into the
actual style formatting. I then use the following macro to now make all of
these formatting attributes to be incorporated into a pre-existing style
which has attributes I don't want but which I have to use (company protocol).
[I use the direct formatting because it's faster and easier than navigating
through all the Style settings and you have the visual of what the paragraph
looks like right in front of you]. The code works nicely sometimes and other
times I get a runtime error 4194 and when you go into Debug it is halting on
the OrganizerDelete statement. What I’ve done is copied that statement into
a new macro all by itself. I then create the Cs style and know it is there
in the Organizer (though it may not be in use in the document and maybe this
is what’s creating a problem????), yet when I run this new macro it will not
delete the style from the Organizer. So, in essence I need to have a
statement that will delete Cs in the Organizer regardless of whether the
style is being used in the document. Anybody have a solution. Thanks for
your help.
Sub CopyAttributesOfStyle()
'ShortcutKey = F12
Const Error_StyleDoesNotExist = 5941
Dim t As Style, s As Style
Dim trgStyleName As String
trgStyleName = InputBox("Enter the name of the style to create")
Set s = ActiveDocument.Styles("Cs")
On Error Resume Next
Set t = ActiveDocument.Styles(trgStyleName)
If Err.Number = Error_StyleDoesNotExist Then
MsgBox "The style specified does not exist."
GoTo Done
End If
On Error GoTo 0
With t
.BaseStyle = "Normal"
.ParagraphFormat = s.ParagraphFormat
.Font = s.Font
.LanguageID = s.LanguageID
End With
Selection.Style = trgStyleName
Application.OrganizerDelete Source:=ActiveDocument, Name:="Cs", Object:= _
wdOrganizerObjectStyles
Done:
Set s = Nothing
Set t = Nothing
End Sub