Wrox Programmer Forums
|
Beginning VB 6 For coders who are new to Visual Basic, working in VB version 6 (not .NET).
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning VB 6 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 August 27th, 2004, 12:27 AM
Registered User
 
Join Date: Aug 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default Unable to create Excel object

Hi

What i m trying to do is quite simple.
I have retrieved data from my SQL database and displayed it in my VB application through a list view control. Now I want that at a click of a button this displayed data should get exported to an excel file (created on the fly)

But the problem is that I m unable to create an object of excel in my VB application. I have referenced the "Excel Object Library" and m trying to create an object the following way:

Set oXL = OLEExcel.object.Application
But the object does not get created :(

Any help
 
Old September 28th, 2004, 10:06 AM
Authorized User
 
Join Date: Sep 2004
Posts: 55
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to Lalit_Pratihari
Default

Hi Neha,

You can do the following:

Refer to Microsoft Excel 9.0 Object Library.

Use the following Code:

Dim ExcelApp As Excel.Application
Dim ExcelWSheet As Excel.Worksheet

Set ExcelApp = CreateObject("excel.application")


ExcelApp.Workbooks.Add
Set ExcelWSheet = ExcelApp.ActiveWorkbook.Sheets("Sheet1")

'Assign the values from the database to the excel worksheet
ExcelWSheet.Range("A1") = "Your RecordSet Value"
'And similarly you can populate in the other cells

ExcelApp.ActiveWorkbook.SaveAs "FilePath and FileName"
ExcelApp.ActiveWorkbook.Close
Set ExcelApp = Nothing

Hope this helps,

Thanks,

Lalit
Life Means More...;)





Similar Threads
Thread Thread Starter Forum Replies Last Post
Unable to create database. rupen SQL Server 2005 4 December 6th, 2007 02:39 AM
Unable to create Macro valdetero Excel VBA 0 July 26th, 2007 02:58 PM
one user unable to create xmlhttp object mussitsch Classic ASP XML 2 August 31st, 2006 09:48 AM
create a Line object ,Box object in CR at Runtime? thanhnt Pro VB 6 1 May 16th, 2005 06:51 AM





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