?
Solved

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

Posted on 2008-10-20
3
Medium Priority
?
1,353 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 23

Accepted Solution

by:
irudyk earned 1500 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
Ever visit a website where you spotted a really cool looking Font, yet couldn't figure out which font family it belonged to, or how to get a copy of it for your own use? This article explains the process of doing exactly that, as well as showing how…
This video walks the viewer through the process of creating an MLA formatted document, as well as a bibliography with citations.
This video shows where to find templates, what they are used for, and how to create and save a custom template using Microsoft Word.
Suggested Courses
Course of the Month9 days, 1 hour left to enroll

764 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