Solved

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

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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone 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

Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
This video walks the viewer through the process of creating a watermark for their document, customizing it, and saving it for viewing/printing needs.
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…

832 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