Hi Dan,
The problem is that Object is too general (indeed, as general as it's
possible to get), and the Object type doesn't contain a .Selection
member. A Word.Application object is more specific, and it does
contain a .Selection member.
In a more strongly typed language such as C++ or C#, you could declare
an Object, instantiate it with a pointer to a Word.Application, and
then cast it to Application in order to use its .Selection. That isn't
possible in any VB dialect.
--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.
>I wrote a Microsoft Word automation app in VB, which I am now porting
>to VB script. My initial code looked like this, and works fine:
[quoted text clipped - 22 lines]
>
>Dan
danforest@gmail.com - 05 Apr 2006 17:16 GMT
Thanks Jay.
The problem turned out to be two different behaviors by VB, depending
on how I declared the Word application variable. When using 'Dim o as
Word.Application', and assigning an undeclared variable in
'.Selection.TypeText n', all worked fine. When running the same code
using CreateObject to declare the variable, then I got the type
mismatch error. So that was my bad for not declaring the variable, but
interesting to note the different responses by VB.
Dan
Jay Freedman - 06 Apr 2006 15:19 GMT
Hi Dan,
In VB and VBA, an undeclared variable is implicitly declared as type
Variant. This is usually a bad idea, and it's easily avoided by including
the Option Explicit statement in every module -- see
http://word.mvps.org/FAQs/MacrosVBA/DeclareVariables.htm for the
explanation.

Signature
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.
> Thanks Jay.
>
[quoted text clipped - 7 lines]
>
> Dan