By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,835 Members | 1,454 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,835 IT Pros & Developers. It's quick & easy.

'Type Mismatch' exception when calling Word.Application.Documents.Open method in Office (Word) 2003 PIA from C#

P: n/a
Hi,

I'm getting a 'Type mismatch' exception when calling the
Word.Application.Documents.Open method when using the Office XP 2003
PIAs. the actual error is:

System.Runtime.InteropServices.COMException (0x80020005): Type
mismatch.

This method works when using the Office XP PIAs (not that this fact is
much to go by) but sadly:

1) the number of arguments changes between versions of the PIA
2) this error occurs

Has anyone had a similar problem? My code couldn't be simpler (minus
exception handling):

private static Word.Document openDocument(Word.Application application,
string sFileName)
{
Word.Document dDocument = null;

object oReadOnly = true;
object oIsVisible = false;
object oMissing = System.Reflection.Missing.Value;

dDocument = application.Documents.Open(
ref sFileName,
ref oMissing,
ref oReadOnly,
ref oMissing,
ref oMissing,
ref oMissing,
ref oMissing,
ref oMissing,
ref oMissing,
ref oMissing,
ref oMissing,
ref oIsVisible,
ref oMissing,
ref oMissing,
ref oMissing,
ref oMissing);

return dDocument;
}

Can anyone help?! Alternatives/workarounds/hair replacement therapy all
welcome...

Cheers,
Rich

Nov 17 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Ron
try:

Microsoft.Office.Interop.Word.ApplicationClass app = new
Microsoft.Office.Interop.Word.ApplicationClass();

"we******@urbanperspective.net" wrote:
Hi,

I'm getting a 'Type mismatch' exception when calling the
Word.Application.Documents.Open method when using the Office XP 2003
PIAs. the actual error is:

System.Runtime.InteropServices.COMException (0x80020005): Type
mismatch.

This method works when using the Office XP PIAs (not that this fact is
much to go by) but sadly:

1) the number of arguments changes between versions of the PIA
2) this error occurs

Has anyone had a similar problem? My code couldn't be simpler (minus
exception handling):

private static Word.Document openDocument(Word.Application application,
string sFileName)
{
Word.Document dDocument = null;

object oReadOnly = true;
object oIsVisible = false;
object oMissing = System.Reflection.Missing.Value;

dDocument = application.Documents.Open(
ref sFileName,
ref oMissing,
ref oReadOnly,
ref oMissing,
ref oMissing,
ref oMissing,
ref oMissing,
ref oMissing,
ref oMissing,
ref oMissing,
ref oMissing,
ref oIsVisible,
ref oMissing,
ref oMissing,
ref oMissing,
ref oMissing);

return dDocument;
}

Can anyone help?! Alternatives/workarounds/hair replacement therapy all
welcome...

Cheers,
Rich

Nov 17 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.