Problems calling MS Word from VB.Net

G

Guest

I'm writing a VB Winforms app, Dot Net 2.0. I simply want to be able to
click on a link (within a datagridview column) and call up docs in MS Word.
I have added a reference to the Microsoft Office 11 Object library.

In my code I have added the lines:
Dim x As New Microsoft.Office.Interop.Word.Application
x.Open(FileName:=s, ReadOnly:=True)

When it isn't complaining about the file not being found, it's returning the
following error message: Public member 'Open' on type 'ApplicationClass' not
found.

I've tried a number of variations on the above open call but I really don't
have any experience working with this lib up to now. Suggestions?
 
J

Jason Newell

Per your stated requirements, the following code will do what you need
w/o the need to reference the Word API.

System.Diagnostics.Process.Start(path);

Jason Newell
Software Engineer
www.jasonnewell.net
 
G

Guest

I'm afraid I'm going to have to ask for a little more help here. I am not
accustomed to using Process.Start. I have tried simply doing a
Process.Start("winword.exe " + s) , where s is the complete name and path of
the file I wish to edit.

I have also tried:
Dim myProcess As New Process
myProcess.StartInfo.FileName = "winword.exe " + s
myProcess.Start()

In both cases I get the error message "The system cannot find the file
specified"

I'm wondering if there's some basic principle of referencing Windows files
that I'm forgetting. (If I simply do a Start("winword.exe"), it comes up
without error.)

In this case the filename/path is extremely simple: c:\download\test.doc
 
G

Guest

My apologies. Ignore previous post. It appears that I've been trying too
hard. Looks like I should sit back and let the system defaults do the work.
(Right?)

Dim myProcess As New Process
myProcess.StartInfo.FileName = s
myProcess.StartInfo.Verb = "Open"
myProcess.Start()

where s is only the doc file name/path.
 

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

Top