Wrox Programmer Forums
|
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA 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 December 17th, 2003, 12:14 AM
Registered User
 
Join Date: Nov 2003
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default SQL 2000 into Excel

I need to get a recordset into an Excel worksheet as follows.
Open the Workbook Template from my VB6 app as a new Workbook.
Insert into the pre-formatted worksheet the recordset with this exception.
The worksheet has 3 sections with the same format and the recordset data needs to be inserted to different areas depending on a column in the SQL db that can have 3 values, hence the 3 sections. So I need to insert rows based on that criteria. I also need to copy the formula if the insert function does not handle it. The VB6 app will have an ADODB recordset already open that I can call. Also the worksheet has columns as dividers so I must account for placing the SQL columns accordingly.
The worksheet template, SQL db and VB6 app are all built and functioning, just need to get the data to the spreadsheet.
That is a lot to ask help on I know
Thanks In Advance!


 
Old December 17th, 2003, 04:00 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 344
Thanks: 0
Thanked 1 Time in 1 Post
Default

check out http://www.greggriffiths.org/webdev/both/excel/ which covers this kind of thing - form a VBScript -> Excel point of view - although some of the links may also be of interest and assistance.
 
Old December 18th, 2003, 05:16 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,212
Thanks: 0
Thanked 1 Time in 1 Post
Default

You can drive this process from SQL Server provided you have a suitable driver installed (all you need is the Jet Access driver - it understands Excel files too). You can set-up a query to insert data into named ranges in a spreadsheet directly from a SQL Server stored procedure or DTS task.

Check out this recent thread in the SQL Server forum http://p2p.wrox.com/topic.asp?TOPIC_ID=7104 (it talks about transferring data the other way - from Excel to SQL - but the principle is the same).

If you want to do it via DTS you can set-up the Excel sheet as the destination and write a SQL query as the source.

Not sure about this bit "I also need to copy the formula if the insert function does not handle it." That may be something you have to do in your VB app after the data transfer.

hth
Phil
 
Old December 31st, 2003, 03:51 AM
Registered User
 
Join Date: Dec 2003
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Guy, you can open a new Excel file, click Tools/Macro/Record New Macro£¬and open Tools/Macro/Visual Basic Editor to monitor your action. now back Excel worksheet, do what you want to do! at the end check sourcecode in VB editor, you will find all sourcecode what you want to get! I usually do VBA developement using this way, it's great!

Quote:
quote:Originally posted by bertlf
 I need to get a recordset into an Excel worksheet as follows.
Open the Workbook Template from my VB6 app as a new Workbook.
Insert into the pre-formatted worksheet the recordset with this exception.
The worksheet has 3 sections with the same format and the recordset data needs to be inserted to different areas depending on a column in the SQL db that can have 3 values, hence the 3 sections. So I need to insert rows based on that criteria. I also need to copy the formula if the insert function does not handle it. The VB6 app will have an ADODB recordset already open that I can call. Also the worksheet has columns as dividers so I must account for placing the SQL columns accordingly.
The worksheet template, SQL db and VB6 app are all built and functioning, just need to get the data to the spreadsheet.
That is a lot to ask help on I know
Thanks In Advance!







Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem in opening excel file in MS Excel 2000 kallol Visual C++ 0 November 16th, 2007 05:48 AM
SQL Server 2000 DTS Excel Import Error Tglover SQL Server DTS 0 June 22nd, 2007 12:27 PM
How to parse Excel Spreadsheet to SQL Server 2000 pgkdave Visual Basic 2005 Basics 1 November 22nd, 2006 12:57 PM
looking for access 2000 to sql server 2000 sql/que method SQL Server 2000 0 July 7th, 2005 12:46 PM
Excel in win 2000 to excel winxp (excel 2002) Max Excel VBA 3 August 28th, 2003 04:44 AM





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