how to open a Word document from .NET

  • Thread starter Thread starter Albert
  • Start date Start date
A

Albert

Hello,
I have a solution with a win form project and an office project. I wannt to
open word from my win form application.
Any idea???

Albert
 
Is it my imagination or there is nothing on automation for word 2000/office
2000?

Thanks

Regards
 
The MSDN examples are targeted at Office XP. However, most of them will
work equally well in Office 2000 -- the Office XP type libraries (Version
10) are just a superset of the Office 2000 libraries (Version 9). I'm
actually developing a Word add-in that is backwards compatible with Office
2000 and higher, since a lot of potential customers are still using 2000.

Here's the reference for Office 2000. The examples just need to be
translated from VBA/Visual Basic 6 to VB.Net or C#.

http://msdn.microsoft.com/library/d...eovroffice2000visualbasicprogrammersguide.asp
 
Use my code below, you can open almost anything in windows:

System.Diagnostics.Process openDoc = new System.Diagnostics.Process();

openDoc.EnableRaisingEvents = false;

openDoc.StartInfo.FileName = lsFileName;

openDoc.Start();

openDoc.WaitForInputIdle();

Cheers,



Dennis Huang
 
Sorry, I forgot to tell that I'm using Office 2003.

I have a solution with a windows application project and an word project.
How can I call the word project from the windows application???

Thanx
 
Good idea, but it's generally better to automate Office using its built-in
support for automation.
 
It do not work on my PC at all :( I have used this code and many other
like this, and can print/open only txt documents, but had "file not
found" error on pdf, doc, etc file types. I guess it something
happends with file association? I'm not good at .NET but txt print
association in just notepad /p %1 but all other uses DDE, may be the
reason is here?

Thanks
 
It do not work on my PC at all :( I have used this code and many other
like this, and can print/open only txt documents, but had "file not
found" error on pdf, doc, etc file types. I guess it something
happends with file association? I'm not good at .NET but txt print
association in just notepad /p %1 but all other uses DDE, may be the
reason is here?

Thanks
 
Hello,

Slava ilyin said:
It do not work on my PC at all :( I have used this code and many other
like this, and can print/open only txt documents, but had "file not
found" error on pdf, doc, etc file types. I guess it something
happends with file association? I'm not good at .NET but txt print
association in just notepad /p %1 but all other uses DDE, may be the
reason is here?

Notice that the application associated with the file format must support
printing the files.
 
It's actually the same as double clicking a file when you want to open it.

Dennis
 

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

Back
Top