Exporting to Excel 
Author Message
 Exporting to Excel

Hi

I have a database that contains a few records, i would like to be able
to click a button in a VB program and have some of the fields from the
database be transferred over to Excel in an existing excel workbook.

I've done something like

Dim xlApp As Excel.Application
Dim xlBook As Excel.Workbook
Dim xlSheet As Excel.Worksheet
Set xlApp = New Excel.Application

xlApp.Visible = True
xlApp.Workbooks.Open App.Path & "\upland.xls"
Dim xlRange As Excel.Range

        Set xlRange = xlApp.Range("G9")
        xlRange = "Agreement # 1"

        Set xlRange = xlApp.Range("c9")
        xlRange = "500"

        Set xlRange = xlApp.Range("b10")
        xlRange = "Agreement # 2"

        Set xlRange = xlApp.Range("d10")
        xlRange = "100"

' Now this works fine if i had time to write code for each individual
cell, but there is a field in the database called RAN, and i'd like
all the records RAN field to be filled into excel in Column's G9 to
G19.

I don't know if i'm confusing or not, but if you're interested in
helping me, please reply and i will try to explain better, or you can

Thank you very Much in Advance

Khalid Rahaman

Signup for FREE DSL
http://www.*-*-*.com/ ,100013725&wf.exe



Sat, 21 Sep 2002 03:00:00 GMT  
 Exporting to Excel

MS KB articles, 247412 and 219151 should help you get on track.  Instead
of transferring data cell by cell, you can put data in an array and then
assign the array to EXCEL cells.

Quote:

> Hi

> I have a database that contains a few records, i would like to be able
> to click a button in a VB program and have some of the fields from the
> database be transferred over to Excel in an existing excel workbook.

> I've done something like

> Dim xlApp As Excel.Application
> Dim xlBook As Excel.Workbook
> Dim xlSheet As Excel.Worksheet
> Set xlApp = New Excel.Application

> xlApp.Visible = True
> xlApp.Workbooks.Open App.Path & "\upland.xls"
> Dim xlRange As Excel.Range

>         Set xlRange = xlApp.Range("G9")
>         xlRange = "Agreement # 1"

>         Set xlRange = xlApp.Range("c9")
>         xlRange = "500"

>         Set xlRange = xlApp.Range("b10")
>         xlRange = "Agreement # 2"

>         Set xlRange = xlApp.Range("d10")
>         xlRange = "100"

> ' Now this works fine if i had time to write code for each individual
> cell, but there is a field in the database called RAN, and i'd like
> all the records RAN field to be filled into excel in Column's G9 to
> G19.

> I don't know if i'm confusing or not, but if you're interested in
> helping me, please reply and i will try to explain better, or you can

> Thank you very Much in Advance

> Khalid Rahaman

> Signup for FREE DSL
> http://i.winfire.com/s/isapiEng.dll/wf.exe?cmd=rl&507,100013725&wf.exe



Sat, 21 Sep 2002 03:00:00 GMT  
 Exporting to Excel
Khalid

You could try using cells rather than the range and you should be
able to use x,y variables i.e. rather than .range ("G9") you can use
.cells(9,7).value and loop through your record set

the (9,7) numbers can be replaced with variable names so you can
use a for next to reference the cells you want.

Dave

Quote:

> Hi

> I have a database that contains a few records, i would like to be able
> to click a button in a VB program and have some of the fields from the
> database be transferred over to Excel in an existing excel workbook.

> I've done something like

> Dim xlApp As Excel.Application
> Dim xlBook As Excel.Workbook
> Dim xlSheet As Excel.Worksheet
> Set xlApp = New Excel.Application

> xlApp.Visible = True
> xlApp.Workbooks.Open App.Path & "\upland.xls"
> Dim xlRange As Excel.Range

>         Set xlRange = xlApp.Range("G9")
>         xlRange = "Agreement # 1"

>         Set xlRange = xlApp.Range("c9")
>         xlRange = "500"

>         Set xlRange = xlApp.Range("b10")
>         xlRange = "Agreement # 2"

>         Set xlRange = xlApp.Range("d10")
>         xlRange = "100"

> ' Now this works fine if i had time to write code for each individual
> cell, but there is a field in the database called RAN, and i'd like
> all the records RAN field to be filled into excel in Column's G9 to
> G19.

> I don't know if i'm confusing or not, but if you're interested in
> helping me, please reply and i will try to explain better, or you can

> Thank you very Much in Advance

> Khalid Rahaman

> Signup for FREE DSL
> http://i.winfire.com/s/isapiEng.dll/wf.exe?cmd=rl&507,100013725&wf.exe



Mon, 23 Sep 2002 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Crystal Enterprise Exports to Excel 5 format instead of Excel 7

2. Newbie:export to Excel

3. How to export to Excel then open it?

4. Export to Excel

5. Export to Excel

6. Exporting to Excel

7. Access - Export to Excel.. Multiple sheets

8. Export to Excel sans Header

9. Export to excel spreadsheets

10. Export to Excel with Special Formatting

11. Add creation date to filename when exporting to Excel

12. Help !! Problem exporting to excel

 

 
Powered by phpBB® Forum Software