Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 2008 > Visual Basic 2008 Essentials
| Search | Today's Posts | Mark Forums Read
Visual Basic 2008 Essentials If 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 Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 21st, 2009, 03:58 AM
Authorized User
 
Join Date: Mar 2008
Location: , , Russia.
Posts: 74
Thanks: 2
Thanked 0 Times in 0 Posts
Send a message via ICQ to sektor
Default 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()

xlBook = xlApp.Workbooks.Add()
xlSheet = xlBook.Worksheets("Sheet1")

xlApp.Visible = True

End Sub




Similar Threads
Thread Thread Starter Forum Replies Last Post
Connect to SQL Database with Visual Basic 2008 enizag VB Databases Basics 5 October 22nd, 2008 12:04 PM
Error on Visual Basic 6 Install File with CR XI R2 jmss66 Crystal Reports 0 August 25th, 2008 10:41 AM
visual basic in excel help me pakmaniac Access VBA 2 January 2nd, 2004 10:55 AM
Excel-Visual basic kasimg Excel VBA 1 August 9th, 2003 03:39 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.