iam new to vb and trying to create a front page for my excel program.
I am trying to use a vb express form to browse for a excel file via a button then open the selected file.
have been workin on this for 4 days now with out any luck.
this is the code i have so far.
i thought this would of been quite easy as vb & excel should work together!!
the btnOpenExistingProject will browse for a existing file and the btnOpenNewProject will open a specific file.
Option Explicit On
Public Class ufmTheEstimator
Private moApp As Excel.Application
Private Sub btnOpenExistingProject_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOpenExistingProject.Click
Dim myStream As IO.Stream
Dim openFileDialog1 As New OpenFileDialog()
openFileDialog1.InitialDirectory = "My Documents:\"
openFileDialog1.Filter = "Excel files (*.xls)|*.xls|All files (*.*)|*.*"
openFileDialog1.FilterIndex = 2
openFileDialog1.RestoreDirectory = True
If openFileDialog1.ShowDialog() = Windows.Forms.DialogResult.OK Then
myStream = openFileDialog1.OpenFile()
If Not (myStream Is Nothing) Then
'THIS IS WHERE I NEED THE CODE TO OPEN THE SELECTED FILE( I THINK)
Private Sub btnOpenNewProject_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOpenNewProject.Click
Dim oXLApp As Excel.Application 'Declare the object variables
Dim oXLBook As Excel.Workbook
oXLApp = New Excel.Application 'Create a new instance of Excel
'oXLBook = oXLApp.Workbooks.Add 'Add a new workbook
oXLApp.Visible = True 'Show it to the user
oXLBook = oXLApp.Workbooks.Open("c:\Jobs\WillmattRoofing-12.xls") 'Open an existing workbook
oXLApp = Nothing
iam also haveing a problem with this line in the second sub "New Excel.Application" it needs declaring but i carnt work out how.
any help appreicated