Topaz Filer - Email filing software
interop problems
Messages   Related Types
This message was discovered on microsoft.public.vsnet.vstools.office.


SteveG
GOOD ANSWER
interop problems.. using Vb.net 2002
using MS Word 9.0 objects as reference.
computer running xp pro
MS Word2000

''Keep getting this same error... INVALID CAST EXCEPTION''

    TRIED USING EXCEL EXAMPLE AND I GET THE SAME ERROR
any ms office example I try to run fails....

System.InvalidCastException: QueryInterface for interface
Word._Application failed.
at Word.ApplicationClass.get_Application()
at WordMailMerge.Form1.Button1_Click(Object sender,
EventArgs e) in C:\Documents and

Settings\Steve\Desktop\VB.NET - Windows Forms - Simple
Printing\WordMailMerge\Form1.vb:line 94
at System.Windows.Forms.Control.OnClick(EventArgs e)

on button click in Vb.net
'Start Word and open the document template.
93 oWord = CreateObject("Word.Application") 'this
line runs
94 oWord.Application.Visible = True ''''this
line FAILS
95 oWord.Visible = CBool(True) ''this line
fails also

get same result if I comment out line 94 and run line 95

I put this line at the top of the form module
Imports Word = Microsoft.Office.Interop.Word 'it put a
squigly line under ms.office.interop.word'

'mouse over line says "Namespace or type "Word" for the
imports Microsoft.Office.Interop.Word' cannot be found
Reply to this message...
Vote that this is a GOOD answer... (26 votes from other users already)
 
 
    
nat
GOOD ANSWER
Anyway it failed since you should use oWord.Visible rather than
oWord.Application.Visible

"SteveG" <Click here to reveal e-mail address> wrote in message
news:03ff01c31be4$3f43fea0$Click here to reveal e-mail address...
[Original message clipped]

Reply to this message...
Vote that this is a GOOD answer... (31 votes from other users already)
 
 
    
Richie Weldon [MSFT]
GOOD ANSWER
Hi Steve,

It looks like you're trying to develop a solution using Microsoft Word 9.0.
You may want to post this message in one of the Word newsgroups (like
microsoft.public.word.programming). This newsgroup is designed for people
having trouble with the Visual Studio Tools for Office product. (Please
see http://msdn.microsoft.com/vstudio/office/ for more information
regarding Visual Studio Tools for Office.)

Richie Weldon
Trinity - Customer Solutions QA team

--

This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm
--------------------
<< Content-Class: urn:content-classes:message
<< From: "SteveG" <Click here to reveal e-mail address>
<< Sender: "SteveG" <Click here to reveal e-mail address>
<< Subject: interop problems
<< Date: Fri, 16 May 2003 12:49:22 -0700
<< Lines: 38
<< Message-ID: <03ff01c31be4$3f43fea0$Click here to reveal e-mail address>
<< MIME-Version: 1.0
<< Content-Type: text/plain;
<<     charset="iso-8859-1"
<< Content-Transfer-Encoding: 7bit
<< X-Newsreader: Microsoft CDO for Windows 2000
<< Thread-Index: AcMb5D9D+Dgma7+rTdethgR3JcEw4Q==
<< X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
<< Newsgroups: microsoft.public.vsnet.vstools.office
<< Path: cpmsftngxa06.phx.gbl
<< Xref: cpmsftngxa06.phx.gbl microsoft.public.vsnet.vstools.office:322
<< NNTP-Posting-Host: TK2MSFTNGXA09 10.40.1.161
<< X-Tomcat-NG: microsoft.public.vsnet.vstools.office
<<
<< interop problems.. using Vb.net 2002
<< using MS Word 9.0 objects as reference.
<< computer running xp pro
<< MS Word2000
<<
<< ''Keep getting this same error... INVALID CAST EXCEPTION''
<<
<<     TRIED USING EXCEL EXAMPLE AND I GET THE SAME ERROR
<< any ms office example I try to run fails....
<<
<< System.InvalidCastException: QueryInterface for interface
<< Word._Application failed.
<< at Word.ApplicationClass.get_Application()
<< at WordMailMerge.Form1.Button1_Click(Object sender,
<< EventArgs e) in C:\Documents and
<<
<< Settings\Steve\Desktop\VB.NET - Windows Forms - Simple
<< Printing\WordMailMerge\Form1.vb:line 94
<< at System.Windows.Forms.Control.OnClick(EventArgs e)
<<
<< on button click in Vb.net
<< 'Start Word and open the document template.
<< 93 oWord = CreateObject("Word.Application") 'this
<< line runs
<< 94 oWord.Application.Visible = True ''''this
<< line FAILS
<< 95 oWord.Visible = CBool(True) ''this line
<< fails also
<<
<< get same result if I comment out line 94 and run line 95
<<
<<
<< I put this line at the top of the form module
<< Imports Word = Microsoft.Office.Interop.Word 'it put a
<< squigly line under ms.office.interop.word'
<<
<< 'mouse over line says "Namespace or type "Word" for the
<< imports Microsoft.Office.Interop.Word' cannot be found
<<

Reply to this message...
Vote that this is a GOOD answer... (29 votes from other users already)
 
 
 
System.EventArgs
System.InvalidCastException
System.Windows.Forms.Control




Topaz Filer - Email filing software
Ad
BootFX
Reliable and powerful .NET application framework.
Looking to invest in a major software project? Technical and commercial advice available here.
Other Helpful Sites
MBR 247
Topaz Filer
SharePoint Email Filing
Software Advisory Services
 
Copyright © AMX Software Ltd 2008-2010. Portions copyright © Matthew Baxter-Reynolds 2001-2010. All rights reserved.
Contact Us - Terms of Use - Privacy Policy - 4.0.30129.1734