Hi!
I have an Excel workbook in My.Resources. I want to open it when I use a button. I don't know how to do it Do you have any idea
I can do it by opening the file from its adress (see bellow). I want to do the same job with the excel file from the Resources.
Thanks for your help....
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.ClickxlsApp =
New Excel.Application With xlsApp .Visible = True.Workbooks.Open(
"D:\Documents\Fred.xls")End With
End Sub
Open an excel workbook from My.Resources
rgny
Thank you for that but I don't understand what you are saying. Don't you think it s possible to open directly the excel file from VB (I use the 2005 express edition)
The file is known as an excel file when I save it in the resources. That's why I thougth it was possible to open it directly as an excel workbook.
Please give more infos on the binary method you are speaking about. What s a binary reader I don't want to open the file from the disk but from the resources.
Thanks
Ross Miltenberg
Kuik
Well I'm not to sure if you can open an excel file directly from memory...that why i suggested using the biinary writer:
Private
Sub TestResource() Dim TempFileName As String = "MyXlsFile.xls" TempFileName = Application.StartupPath & "\" & TempFileName Dim fs As New FileStream(TempFileName, FileMode.Create, FileAccess.Write) Dim fsR As New BinaryWriter(fs) fsR.Write(My.Resources.MyXlResource, 0, My.Resources.MyXlResource.Length) fsR.Close() fs.Close() xlsApp = New Excel.Application With xlsApp .Visible = True.Workbooks.Open(
TempFileName)End With
End SubSwatanya
Thanks a lot Dman1!
It looks to work perfectly