DiverDan
Well-known member
Im getting an invalid path error when starting MS Word from Process.Start with a OpenFileDialog filename. Other applications like NotePad and Excel work fine...the problem is only with Word. Does anyone have an idea to solve this problem.
Heres the code Im using:
Thanks
Heres the code Im using:
Code:
OpenFileDialog1.Title = "Open Contract Files"
OpenFileDialog1.InitialDirectory = Application.StartupPath & "\Contracts"
OpenFileDialog1.Filter = "Contracts (*.doc)|*.doc|Worksheets (*.xls)|*.xls|All Files (*.*)|*.*"
OpenFileDialog1.DefaultExt = "doc"
OpenFileDialog1.AddExtension = True
If OpenFileDialog1.ShowDialog() = DialogResult.Cancel Then Exit Sub
If OpenFileDialog1.FileName.IndexOf(".txt") >= 0 Then
System.Diagnostics.Process.Start("notepad.exe", OpenFileDialog1.FileName)
ElseIf OpenFileDialog1.FileName.IndexOf(".doc") >= 0 Then
System.Diagnostics.Process.Start("WINWORD.EXE", OpenFileDialog1.FileName)
ElseIf OpenFileDialog1.FileName.IndexOf(".xls") >= 0 Then
System.Diagnostics.Process.Start("EXCEL.EXE", OpenFileDialog1.FileName)
End If
Thanks