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 users to be able 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? Security switch for readonly access?

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") 'the string in
strHelpDocumentPath

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
 
R

Robin Tucker

You could try an exception handler to catch this message around your process
start. I assume it starts and opens the document in any case, so all you
want to do is prevent it throwing out of your program.

try

Process.Start

Catch whatevertheexceptionisCOMException

End Try
 

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