Visual Basic 2008 EssentialsIf you are new to Visual Basic programming with version 2008, this is the place to start your questions.
Welcome to the p2p.wrox.com Forums.
You are currently viewing the Visual Basic 2008 Essentials section of the Wrox p2p Programmer to Programmer discussion community. This is a community of more than 40,000 computer programmers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining our free Wrox p2p community you can post your own programming questions and respond to other programmers’ questions. Registered users also don't have to see the ads that are displayed to guests. Registration is fast, simple and absolutely free so please, join today!
Join today and post to win prizes! Post more to increase your chances of being Wrox’s top poster of the month.
Error when create Excel 2007 file in Visual Basic 2008
I wanna create an empty Excel 2007 file thru Visual Basic 2008. I added reference to "Microsoft Excel 12.0 Object Library" from "COM" tab of "Add reference" window.
I wrote following code, but it fails to run - VS 2008 points on "xlBook = xlApp.Workbooks.Add()" line and says - "Old format is used or library has wrong type. (Exception from HRESULT: 0x80028018 (TYPE_E_INVDATAREAD))"
What is the reason?
Code (on usual button):
Option Strict Off
Imports MyExcel = Microsoft.Office.Interop.Excel
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim xlApp As New MyExcel.Application()
Dim xlBook As MyExcel.Workbook
Dim xlSheet As MyExcel.Sheets()