Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Open Microsoft Word document from VB.NET. 1

Status
Not open for further replies.

sreeramnavale

Programmer
Feb 18, 2004
40
US
How do I open Microsoft word from VB.NET application, opening any perticular word document (say Report.doc)?

SN
 
Dim prc As New Process()

prc.Start("Report.doc")


This will only work if Word is installed properly and the .doc file association is set to Word.
 
Add a reference to Microsoft Word to your project. It is in the COM tab, when adding references.
Code:
Dim o As New Word.Application
o.Documents.Open("c:\report.doc")
o.ShowMe()





Sweep
...if it works dont mess with it
 
The "Shell" command used to work in VB6, not

sure about .NET

goes like this...

Shell("c:\WHATEVER THE PATH IS TO THE DOCUMENT\DOCUMENT NAME.DOC ")
 
Thank you Sweep.
And
Thank you Martin.

Both of your tips worked.

Sreeram
 
Hi Sweep,

I tried your solution and this is what happens to me. The program runs fine but does not seem to open the named word doc ("c:\Report Details") or any doc at all. I have this set to a report button click event so if I click the button again, it runs through again, however this time I get the Office notifaction that the document is in use and would I like to see a read only version of the document. I click yes and the document appears! Would anyone out there have any ideas as to what might be causing this?

Thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top