Problems calling MS Word from VB.Net

  • Thread starter Thread starter Guest
  • Start date Start date
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?
 
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
 
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
 
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.
 
Back
Top