OpenWord() problem

suki_ash

New member
Joined
Feb 22, 2007
Messages
3
C#:
private bool OpenWord()
        {
            try
            {
                wordApp = new ApplicationClass();
                tname = (object) templateFileName;
                wordApp.Visible = false;
                //wordDoc = wordApp.Documents.Open(ref tname, ref oMissing,ref oMissing,ref oMissing,ref oMissing,ref oMissing,ref oMissing,ref oMissing,ref oMissing,ref oMissing,ref oMissing,ref oMissing); //for Word 2000
                wordDoc = wordApp.Documents.Open(ref tname, ref oMissing,ref oMissing,ref oMissing,ref oMissing,ref oMissing,ref oMissing,ref oMissing,ref oMissing,ref oMissing,ref oMissing,ref oMissing,ref oMissing,ref oMissing,ref oMissing,ref oMissing); //for Word 2003
                return true;
            }
            catch (Exception ex)
            {
                myLogFile.WriteLine("Error while attempting to open the template." + ex.Message + ex.StackTrace );
                cleanUp();
                wordApp = null;
                return false;
            }
        }
This is my method for opening a word document, but for wordApp.Documents.Open() method will take the parameters depending on the version installed in the machine, so here how can I determine which method to call at runtime.

Please help me....

Thanks,
Subhosh.
 
Last edited by a moderator:
I believe you should consult some reference on Interop Assemblies so that you dont have to worry about the difference in Word version. I have experience the same problem with you. I tried to read some reference about Interop Assemblies but I had to stop because Im not suppose to use any Interop Assemblies in my Application.

Sorry if it didnt help much.
 
Thanks for the reply.

Can you please suggest me some sources about Interop Assemblies.

Thanks,
Subhosh.
 
Back
Top