Application.OrganizerDelete
(1)
ActiveDocument.Styles
(1)
CopyAttributesOfStyle
(1)
WdOrganizerObjectStyles
(1)
StyleDoesNotExist
(1)
Selection.Style
(1)
LanguageID
(1)
ParagraphFormat
(1)

Deleting Styles From Organizer

Asked By jerem
02-Feb-10 07:58 PM
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 do not want but which I have to use (company protocol).
[I use the direct formatting because it is 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

tforng Iinto thel ofol).

Larry Sulky replied to jerem
05-Feb-10 02:32 PM
t
for
ng I
into the
l of
ol).
ating
aph
other
on
nt into
here
his
l not
s for
)

Give the name of the active document:

Application.OrganizerDelete Source:=3DActiveDocument.FullName,
Name:=3D"Cs", Object:=3D _
wdOrganizerObjectStyles

--larry

I want to use this feature on any document that I am in that I have to

jerem replied to Larry Sulky
16-Feb-10 06:00 PM
I want to use this feature on any document that I am in that I have to format
paragraphs for (which may be several paragraphs in the same document).
Becomes tedious to have to specify a name every time I want to use the macro.
Any way of getting around having to specify the name of the document.  Just
curious why ActiveDocument is not sufficient?
Post Question To EggHeadCafe