I have a windowsform where I have a listbox who displays all the pdf files in a folder, I select one of them and push a button and it shows in a webbrowsercontrol I have added to my form.
But I know wants to have a similar form for my doc files but when I try to open my doc files word starts up and displays the file in word instead of in my form.
How can I display the wordfile in my form instead of MS-word????
The code for the pdf form look like this.
Imports Bytescout.PDF
Imports System
Imports System.IO
Public Class DocArch
Inherits System.Windows.Forms.Form
Dim ReportName As String
Dim oDocument As Object
Private Sub DocArch_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim Path As String = My.Application.Info.DirectoryPath
If Not Directory.Exists(Path & "\Temp_Pdf") Then
Directory.CreateDirectory(Path & "\Temp_Pdf")
End If
If File.Exists(Path & "\Temp_Pdf\" & ReportName & ".pdf") Then
Try
File.Delete(Path & "\Temp_Pdf\" & ReportName & ".pdf")
Catch ex As Exception
MsgBox("Error - " & ex.Message)
End Try
End If
Dim vFileName As String = Path & "\Temp_Pdf\" & ReportName & ".pdf"
FillList()
End Sub
Public Sub FillList()
Dim folderInfo As New IO.DirectoryInfo(My.Application.Info.DirectoryPath)
Dim arrFilesInFolder() As IO.FileInfo
Dim fileInFolder As IO.FileInfo
arrFilesInFolder = folderInfo.GetFiles("*.pdf")
For Each fileInFolder In arrFilesInFolder
ListBox1.Items.Add(fileInFolder.Name)
Next
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim myFile As String = ListBox1.SelectedItem
Dim test1 As String = My.Application.Info.DirectoryPath
Dim test2 As String = test1 + "\" + myFile
'MsgBox("Variabelen er : " & test2, MsgBoxStyle.ApplicationModal)
If test2.Length Then
oDocument = Nothing
WebBrowser1.Navigate(test2)
End If
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
WebBrowser1.Print()
End Sub
End Class