Question Delete word style

anil3b2

Member
Joined
Jun 19, 2009
Messages
14
Programming Experience
1-3
In word some character styles automatically created like " Char Char1", " Char Char2" etc., [Note Space is there before Char]. we need to remoce this style names.

Dim wordfile As String = "D:\Trash\krishnan.doc"
Dim MSword As New Word.Application
Dim WordDoc As New Word.Document
WordDoc = MSword.Documents.Open(CType(wordfile, Object))
WordDoc.Activate()
For Each style As Word.Style In MSword.ActiveDocument.Styles
If (style.NameLocal = " Char Char") Then
MsgBox(CType(style.LinkStyle, Object))
style.Delete()

End If
Next
MsgBox("Se")
WordDoc.Close(True)
MSword.Quit()

i am using this code to delete and i have saved this using record macro. it's fine to delete manually these style names but if we do thru macro then it's showing the belwo error.

Run time error 5941. The request member of the collection does not exist.

How can i solve this priblem?

Can anybody suggest me on this?
 
Back
Top