Hello
I have written a Windows Forms app in VB.NET 2010. I need to be able to open a user-selected document. The document could be a Word or Excel File or a PDF.
The code I am using to open the document is:
Dim fname As String = strDocumentsFolder & "\" & txtDocument.Text
'Is document an Excel, Word document?
If InStr(LCase(txtDocument.Text), ".doc") > 0 _
Or InStr(LCase(txtDocument.Text), ".xl") > 0 Then
Try
'Yes, so use Process.Start. This works in Windows 7 and Windows 8
Process.Start(fname)
Catch ex As Exception
resp = MessageBox("Sorry. Unable to open " & strDocumentsFolder & "\" & txtDocument.Text & "|E|Cannot Open Document!")
End Try
Else
'document is a PDF
MyBrowser.Navigate(fname)
MyBrowser.Visible = True
End If
(Where MyBrowser is a WebBrowser control)
I need to deploy this application to computers that may not have Acrobat Reader installed, hence the use of the WebBrowser control.
Everything works fine in Windows 7 and Windows XP, but in Windows 8, the MyBrowser.Navigate(fname) switches to the Windows Reader Metro system and opens the PDF there and getting back to my application is a long tortuous route!! I just want the PDF to open in the WebBrowser control and stop it opening Windows Reader Metro system.
Can anyone offer any help on this please?
Thanks in advance
Patrick
I have written a Windows Forms app in VB.NET 2010. I need to be able to open a user-selected document. The document could be a Word or Excel File or a PDF.
The code I am using to open the document is:
Dim fname As String = strDocumentsFolder & "\" & txtDocument.Text
'Is document an Excel, Word document?
If InStr(LCase(txtDocument.Text), ".doc") > 0 _
Or InStr(LCase(txtDocument.Text), ".xl") > 0 Then
Try
'Yes, so use Process.Start. This works in Windows 7 and Windows 8
Process.Start(fname)
Catch ex As Exception
resp = MessageBox("Sorry. Unable to open " & strDocumentsFolder & "\" & txtDocument.Text & "|E|Cannot Open Document!")
End Try
Else
'document is a PDF
MyBrowser.Navigate(fname)
MyBrowser.Visible = True
End If
(Where MyBrowser is a WebBrowser control)
I need to deploy this application to computers that may not have Acrobat Reader installed, hence the use of the WebBrowser control.
Everything works fine in Windows 7 and Windows XP, but in Windows 8, the MyBrowser.Navigate(fname) switches to the Windows Reader Metro system and opens the PDF there and getting back to my application is a long tortuous route!! I just want the PDF to open in the WebBrowser control and stop it opening Windows Reader Metro system.
Can anyone offer any help on this please?
Thanks in advance
Patrick