Re: Open Office document using C#

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Hi,

Another question please,

Now that i know how to open and display word document, how can i open and
display excel files and power point files?

Thanks,
Gidi

"Norman Yuan" wrote:


"Gidi" <shnapsi@xxxxxxxxxxxxxxxxxxxx> wrote in message
news:2120EBD8-34A6-40C4-8263-66EB7EEA94AC@xxxxxxxxxxxxxxxx
Hi,

I've dataBase conating office files, I'm able to get them from the
dataBase,
but I'm looking for a way to open it for the user, to work normaly (like
he
doubled-clicked on the file).

I tried this code:
Microsoft.Office.Interop.Word.ApplicationClass WordApp = new
Microsoft.Office.Interop.Word.ApplicationClass();


Add this line:

WordApp.Visible=true;


Microsoft.Office.Interop.Word.Document aDoc =
WordApp.Documents.Open(ref fileName, ref missing, ref readOnly,
ref missing, ref missing, ref missing, ref missing, ref
missing, ref missing,
ref missing, ref missing, ref isVisible, ref missing,
ref missing, ref missing);

aDoc.Activate();


The result is that a winWord process is running, but i can't see the
document.

another questions is, if there's a general way to open a file
(doc,excel,ppt
and so).


Most "files" created by different applications (Word, Excel, PPT) can only
be opened by its native application. So, the general way is to use the
application to open it, as you have done in your code. Of course you can
open any file and start reading its data in binary format, the catch would
be you have no way to know what the 0s and 1s mean, because the file format
is business secret of the aplications' vender.




Thanks,
Gidi.


.