Process.Start("Winword.exe") problem

D

Dean Slindee

The code below is being used to launch WinWord.exe from a VB.NET program.
Word launches, but displays this error message:

"Word has experienced an error trying to open the file. Try these
suggestions. 1) Check the file permissions for the document or drive. 2)
Make sure there is sufficient free memory and disk space. 3) Open the file
with the Text Recovery converter."

The document that I want to display is on my PC and was created by me. I
ultimately want to open the document in READONLY mode, if possible. Is
there a security switch in the Process.Start statement that I can set to
override the error message?

Here is the code:

Private Sub frmAppointmentWorker_HelpRequested(ByVal sender As Object,
ByVal hlpevent As System.Windows.Forms.HelpEventArgs) Handles
MyBase.HelpRequested

Dim strHelpDocumentPath As String

'determine whether a Help file exists

strHelpDocumentPath = gstrHelpPath & Me.Name & ".doc"

If File.Exists(strHelpDocumentPath) Then

'launch Word

Process.Start("WinWord.exe", strHelpDocumentPath)

'Process.Start("WinWord.exe", "C:\Projects\Human
Services\Documents\Help\frmAppointmentWorker.doc")

Else

MessageBox.Show("A Help document for " & Me.Name & " does not yet
exist.", "Help document not found", MessageBoxButtons.OK,
MessageBoxIcon.Information)

End If

hlpevent.Handled = True

End Sub



Thanks in advance,

Dean Slindee
 
S

Stephany Young

For starters you have a space between 'Human' and 'Services'. I'm certain
that you will have to quote the string to make it work.

If that is, in fact the case, then winword can't find the file. If you think
that the error message is inappropriate then take it up with a winword
group. It is winword throwing the message, not your application.
 
M

MeltingPoint

For starters you have a space between 'Human' and 'Services'. I'm
certain that you will have to quote the string to make it work.

If that is, in fact the case, then winword can't find the file. If you
think that the error message is inappropriate then take it up with a
winword group. It is winword throwing the message, not your
application.

Process.Start("WinWord.exe", strHelpDocumentPath)
I think it's ths line, have a look here:

http://msdn.microsoft.com/library/default.asp?url=/library/en-
us/cpref/html/frlrfsystemdiagnosticsprocessclassstarttopic.asp

It should be Process.Start(strHelpDocumentPath)
The file extention is used to determin what app opens it as stated here:

Starting a process by specifying its file name is similar to typing the
information in the Run dialog box of the Windows Start menu. Therefore,
the file name does not need to represent an executable file. It can be
of any file type for which the extension has been associated with an
application installed on the system. For example the file name can have
a .txt extenstion if you have associated text files with an editor, such
as Notepad, or it can have a .doc if you have associated .doc files with
a word processing tool, such as Microsoft Word.

http://msdn.microsoft.com/library/default.asp?url=/library/en-
us/cpref/html/frlrfsystemdiagnosticsprocessclassstarttopic3.asp
 
C

Cor Ligthert

Dean,

A sample with notepad, however in my opinion exactly the same as your
question.
\\\Notepad
Dim p As New Process
Dim pi As New ProcessStartInfo
pi.arguments = "c:\windows\win.ini"
pi.FileName = "notepad.exe"
p.startinfo = pi
p.Start()
///

I hope this helps,

Cor
 

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