Jump to content
Xtreme .Net Talk

Recommended Posts

Posted (edited)

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.

Edited by PlausiblyDamp
Posted

I believe you should consult some reference on Interop Assemblies so that you don't 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 I'm not suppose to use any Interop Assemblies in my Application.

 

Sorry if it didn't help much.

Amir Syafrudin
Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...