Quantcast
Channel: Excel within a form
Viewing all articles
Browse latest Browse all 2

Excel within a form

0
0

Hi, I need to open an excel worksheet within a form I have created in VB.  I have done this by adding a webbrowser object to the form.  Unfortunately I don't have any excel toobars displayed and can't work out how to enable them.  I would appreciate it someone could help me out.  The code I have on the form is displayed below :

 

Public

Class frmOpenXLTest

Dim strFileName AsString

Dim oDocument AsObject

PrivateSub btnBrowse_Click(ByVal sender As System.Object, _

ByVal e As System.EventArgs) Handles btnBrowse.Click

'Find the Office document.

With OpenFileDialog1

.FileName =

""

.ShowDialog()

strFileName = .FileName

EndWith

'If the user does not cancel, open the document.

If strFileName.Length Then

'oDocument = Nothing

WebBrowser1.Navigate(strFileName)

EndIf

EndSub

 

PrivateSub frmXLTest_Load(ByVal sender AsObject, ByVal e As _

System.EventArgs) HandlesMyBase.Load

btnBrowse.Text = "Browse"

With OpenFileDialog1

.Filter =

"Office Documents "& _

"(*.doc, *.xls, *.ppt)|*.doc;*.xls;*.ppt"

.FilterIndex = 1

EndWith

EndSub

 

PrivateSub frmViewXLTest_Closing(ByVal sender AsObject, ByVal e As _

System.ComponentModel.CancelEventArgs) HandlesMyBase.Closing

oDocument = Nothing

frmOptions.Show()

EndSub

 

PrivateSub btnCloseXL_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCloseXL.Click

oDocument = Nothing

Me.Close()

frmOptions.Show()

EndSub

 

PrivateSub WebBrowser1_DocumentCompleted(ByVal sender As System.Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted

Me.Text = strFileName

EndSub

EndClass


Viewing all articles
Browse latest Browse all 2

Latest Images

Trending Articles





Latest Images