Implementing Selection

S

slaprade

I am writing a .NET addin with VB2005 for Office 2007 using VSTO2005SE

I am attempting to select a part of a document (SENTENCE, PARAGRAPH, WORD
whatever) using word.selection which indicated that I needed to implement
selection so I created a class SelectionIMP with Implements
Word.Selection.

That created a large quantity of properties but I get the following two
messages

Error 40 Class 'SelectionImp' must implement 'Property Style() As Object'
for interface 'Microsoft.Office.Interop.Word.Selection'. Implementing
property must have matching 'ReadOnly' or 'WriteOnly' specifiers.

Error 41 'Style' cannot implement 'Style' because there is no matching
property on interface 'Microsoft.Office.Interop.Word.Selection'.

Which is kind of strange since hitting return on the Implements statement
created all the properties I could ever use including

Public Property Style() As Object Implements
Microsoft.Office.Interop.Word.Selection.Style
Get

End Get
Set(ByVal value As Object)

End Set
End Property

which I trimmed down to Get and End Get and added the ReadOnly
qualification. But to no avail

Do I have to use all of this to make a selection in a document from .NET

Stements like
'Dim selection1 As Word.Selection
'Dim returnValue As Word.Paragraphs
'returnValue = selection1.Paragraphs

just produce errors at run time

OIbviously, I don't know how to make a selection of something in a word
document from .NET so can someone give me a hint?
 
C

Cindy M.

Hi =?Utf-8?B?c2xhcHJhZGU=?=,
I am writing a .NET addin with VB2005 for Office 2007 using VSTO2005SE

I am attempting to select a part of a document (SENTENCE, PARAGRAPH, WORD
whatever) using word.selection which indicated that I needed to implement
selection so I created a class SelectionIMP with Implements
Word.Selection.
To select something you need to get the Range, then use the SELECT method.
As an example:

myDoc.Paragraphs(3).Range.Select()

will select the third paragraph in the document object myDoc.
That created a large quantity of properties but I get the following two
messages

Error 40 Class 'SelectionImp' must implement 'Property Style() As Object'
for interface 'Microsoft.Office.Interop.Word.Selection'. Implementing
property must have matching 'ReadOnly' or 'WriteOnly' specifiers.

Error 41 'Style' cannot implement 'Style' because there is no matching
property on interface 'Microsoft.Office.Interop.Word.Selection'.

Which is kind of strange since hitting return on the Implements statement
created all the properties I could ever use including

Public Property Style() As Object Implements
Microsoft.Office.Interop.Word.Selection.Style
Get

End Get
Set(ByVal value As Object)

End Set
End Property

which I trimmed down to Get and End Get and added the ReadOnly
qualification. But to no avail

Do I have to use all of this to make a selection in a document from .NET

Stements like
'Dim selection1 As Word.Selection
'Dim returnValue As Word.Paragraphs
'returnValue = selection1.Paragraphs

just produce errors at run time

OIbviously, I don't know how to make a selection of something in a word
document from .NET so can someone give me a hint?

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top