Word's global Selection definition missing in VB.NET 2003 ?

J

Jeffrey Bradshaw

I have an app that I was developing under VB V6 and have ported it over to
VB.NET with Visual Studio.NET 2003 using Office 2003. Now when I attempt to
compile the program it says that the Selection variable is not defined.
Everything in the documentation says that 'Selection' is a predefined global
variable. It's probably that I'm missing a reference of some kind.

Any help would be greatly appreciated.

TIA - Jeffrey.
 
J

Jonathan West

Hi Jeffrey,

If you qualify the reference to Selection with the name of the object
variable for the Word application, then it will probably work.
 
J

Jeffrey Bradshaw

Thanks for the info.

Here's the code I did:

docWord.BookMarks("\line").Select()
if docWord.Selection.Text = "TEST" then
yadda yadda yadda
end if

This compiles, but when I type docWord. and get a list of properties,
Selection isn't one of them. Which also means that I don't have the list of
properties/methods in the editor.

I actually run the code yet because of other problems with it (my fault).

Will this actually work?

TIA - Jeffrey.
 
J

Jonathan West

Jeffrey Bradshaw said:
Thanks for the info.

Here's the code I did:

docWord.BookMarks("\line").Select()
if docWord.Selection.Text = "TEST" then
yadda yadda yadda
end if

This compiles, but when I type docWord. and get a list of properties,
Selection isn't one of them. Which also means that I don't have the list of
properties/methods in the editor.

I actually run the code yet because of other problems with it (my fault).

Will this actually work?

No, because selection is not a property of a Document object. Selection is a
property of the Application, Pane or Window object.
 

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