chrome2000
asked on
how can I insert an Excel spreadsheet in a Visual Basic 6.0 form
hello everyone:
I need to be able to insert an Excel spreadsheet in a Visual Basic 6.0 form so that users can play with the spreadsheet as they do with Excel. I have seen several Active X components that will do just that but they are not free. there must be a way that you can use something from MS. please i am looking for a solution that will not involve having to buy an ActiveX. code will be great.
thank you in advance
I need to be able to insert an Excel spreadsheet in a Visual Basic 6.0 form so that users can play with the spreadsheet as they do with Excel. I have seen several Active X components that will do just that but they are not free. there must be a way that you can use something from MS. please i am looking for a solution that will not involve having to buy an ActiveX. code will be great.
thank you in advance
you can try look for OLE object that available by default in VB6. You can select it from the ToolBox.
This will also load excels toolbar:
Private Sub Command1_Click()
' open excel file
WebBrowser1.Navigate2 ("C:\Test.xls")
End Sub
Private Sub WebBrowser1_DocumentComple te(ByVal pDisp As Object, URL As Variant)
WebBrowser1.ExecWB OLECMDID_HIDETOOLBARS, OLECMDEXECOPT_DONTPROMPTUS ER
End Sub
Private Sub Command1_Click()
' open excel file
WebBrowser1.Navigate2 ("C:\Test.xls")
End Sub
Private Sub WebBrowser1_DocumentComple
WebBrowser1.ExecWB OLECMDID_HIDETOOLBARS, OLECMDEXECOPT_DONTPROMPTUS
End Sub
ASKER
hello vinnyd79:
I cannot find Projects>Components>Micros oft Internet Controls. do you know the path to the OCX or dll
thank you
I cannot find Projects>Components>Micros
thank you
ASKER
sorry found it
It should be in your system32 dir:
shdocvw.dll
shdocvw.dll
ASKER
hello vinnyd79:
your solution seems to work but the problem is that unless i save the original excel file (which I don't want to do) i can not browser the spreadsheet and get the values on specific columns. is there a way that i can get to the content of the Excel spreadsheet?
thank you
your solution seems to work but the problem is that unless i save the original excel file (which I don't want to do) i can not browser the spreadsheet and get the values on specific columns. is there a way that i can get to the content of the Excel spreadsheet?
thank you
Im not sure what you are trying to do. Do you have a new workbook that is open in Excel that you would like to pull into the vbform?
Try this http://support.microsoft.com/kb/311765
it's the DSOFramer control, it works like Excel
it's the DSOFramer control, it works like Excel
ASKER
hello vinnyd79:
i have placed the web control on the form like you suggested. i am able to display the Excel doc on the web component. the problem now is that I would like to access at the row and col level the content of the excel spreadsheet that the users will modify after following specific rules designed to accomplish a specific task (out of scope on this discussion). is there a way to access the content of the excel spreadsheet "currently" displayed on the web component?
thank you !
i have placed the web control on the form like you suggested. i am able to display the Excel doc on the web component. the problem now is that I would like to access at the row and col level the content of the excel spreadsheet that the users will modify after following specific rules designed to accomplish a specific task (out of scope on this discussion). is there a way to access the content of the excel spreadsheet "currently" displayed on the web component?
thank you !
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
Private Sub Command1_Click()
' open excel file
WebBrowser1.Navigate2 ("C:\Test.xls")
End Sub
Private Sub Command2_Click()
' save data
WebBrowser1.ExecWB OLECMDID_SAVE, OLECMDEXECOPT_DONTPROMPTUS
End Sub