Delete Style using OrganizerDelete method

A

andreas

Dear Experts:
below macro deletes a user-defined style using the OrganizierDelete
method.

I have got a document with SEVERAL user-defined styles that all begin
with A SPACE. For some specific reason I would like to delete All
these user-defined styles beginning with a space.

How am I to change below code to achieve what I want?

Help is much appreciated. Thank you very much in advance.

Regards, Andreas


Sub DelStylesSpecial()

Dim strName As String
Dim strSource As String
Dim intObject As Integer

strName = " UserDefinedStyle"
strSource = ActiveDocument.FullName
intObject = wdOrganizerObjectStyles

Application.OrganizerDelete _
Source:=strSource, _
Name:=strName, _
Object:=intObject
End Sub
 
K

Klaus Linke

andreas said:
Dear Experts:
below macro deletes a user-defined style using the OrganizierDelete
method.

I have got a document with SEVERAL user-defined styles that all begin
with A SPACE. For some specific reason I would like to delete All
these user-defined styles beginning with a space.

How am I to change below code to achieve what I want?

Help is much appreciated. Thank you very much in advance.


Hi Andreas,

Style names usually aren't allowed to start with a space. In the cases I've
seen them anyway, Word created them (as linked styles) by itself, because of
a bug.
The only way I learned how to get rid of them (on these forums) is to save
the document in XML format.
Once the document has been saved in the XML format, those buggy styles can
be deleted.

Regards,
Klaus
 
A

andreas

Hi Andreas,

Style names usually aren't allowed to start with a space. In the cases I've
seen them anyway, Word created them (as linked styles) by itself, because of
a bug.
The only way I learned how to get rid of them (on these forums) is to save
the document in XML format.
Once the document has been saved in the XML format, those buggy styles can
be deleted.

Regards,
Klaus

Hey Klaus,

I will give a try over the weekend and let you know. Regards, andreas
 

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