Solved

Set the type of Style in word (VB.NET)

Posted on 2008-10-20
3
1,342 Views
Last Modified: 2013-11-10
Currently I am developing an addin for word. I need to set the type of a style but it is a read only property and I am unable to set it, anyone help?
Dim oStyle As Word.Style
oStyle = Application.ActiveDocument.Styles.Add("temp")
oStyle = Application.ActiveDocument.Styles("temp")
oStyle.Type = Word.WdStyleType.wdStyleTypeCharacter  <<------------- This is giving me error ! ! !

Open in new window

0
Comment
Question by:KenTan85
3 Comments
 
LVL 23

Accepted Solution

by:
irudyk earned 500 total points
ID: 22795540
The style type is read only in Word.  You need to define it as a character style when you first create it. Try the following to see if it works for you:

Dim oStyle As Word.Style
Set oStyle = Application.ActiveDocument.Styles.Add("temp", Word.WdStyleType.wdStyleTypeCharacter)

Open in new window

0

Featured Post

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Shortcuts in Word Just the other day I had a training for Microsoft and they wanted me to show how well the new Windows and Office behaved on a touch device, which by the way is great, but it was only then that I realized that using keyboard shortc…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
This Experts Exchange video Micro Tutorial shows how to tell Microsoft Office that a word is NOT spelled correctly. Microsoft Office has a built-in, main dictionary that is shared by Office apps, including Excel, Outlook, PowerPoint, and Word. When …

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question