Solved

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

Posted on 2008-10-20
3
1,328 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Using Word 2013, I was experiencing some incredible lag when typing.  Here's what worked for me....
The viewer will learn how to make their project stand out over others by learning how to change colors and shapes, add spaces, change directions, and add bullets to their charts.
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 …

920 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now