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

W

webstuff

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
 
W

webstuff

Sorted it - was actually caused a long way away and was down to Office
2003 not adding PersistentHandler registry keys in the places where
Office XP did. Thanks for the consistency, Microsoft!
 

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