Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default Exporting data from MS-Access to Excel

...need some help (a reference, or book, that will explain how to export data
from Access to Excel) to create a formatted report with sub-totals.

e.g. this is an employee timesheet application that will export data from an
Access query into what must eventually be a report with department and
employee groupings and sub-totals of hours, with drill down on the
sub-totals.

I know how to do the "TransferSpreadsheet" method to get the data into
Excel, but how do I get it into a usable form once it is in Excel.

My guess is it must go into a "data worksheet" which then loads into a
separate "report worksheet", with column headers, sub-totals, formatting
etc.

The "data worksheet" will be updated monthly and the number of rows will
vary each time the report is run.


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,836
Default Exporting data from MS-Access to Excel

Do you know how to subtotal in Excel? If so, turn on the macro recorder,
then go through the steps in Excel. Turn off the macro recorder when you are
done. Take that code and pop it in to this macro (which must be run from
Access):

Option Compare Database



Option Explicit ' Use this to make sure your variables are defined



' One way to be able to use these objects throughout the Module is to
Declare them here, and not in a Sub



Private objExcel As Excel.Application

Private xlWB As Excel.Workbook

Private xlWS As Excel.Worksheet





Sub Rep()



Dim strFile As String



strFile = "C:\path-to-your-file.xls"



€˜Of course, this is just an example; put the actual path to your actual file
here€¦

' Opens Excel and makes it Visible



Set objExcel = New Excel.Application



objExcel.Visible = True



' Opens up a Workbook



Set xlWB = objExcel.Workbooks.Open(strFile)







' Sets the Workseet to the last active sheet - Better to use the commented
version and use the name of the sheet.



Set xlWS = xlWB.ActiveSheet



' Set xlWS = xlWB("Sheet1")





With xlWS ' You are now working with the Named file and the named worksheet

' Your Excel code begins here€¦put your subtotaling Excel Macro right here!!



End With



' Close and Cleanup



xlWB.SaveAs xlSaveFile

xlWB.Close



xlapp.Quit

Set xlapp = Nothing



End Sub

You are trying to control Excel from Access, right. Thats how I
interpreted your post. Again, this code is in Access; it needs to be run
from Access.

Regards,
Ryan---


--
RyGuy


"JimP" wrote:

...need some help (a reference, or book, that will explain how to export data
from Access to Excel) to create a formatted report with sub-totals.

e.g. this is an employee timesheet application that will export data from an
Access query into what must eventually be a report with department and
employee groupings and sub-totals of hours, with drill down on the
sub-totals.

I know how to do the "TransferSpreadsheet" method to get the data into
Excel, but how do I get it into a usable form once it is in Excel.

My guess is it must go into a "data worksheet" which then loads into a
separate "report worksheet", with column headers, sub-totals, formatting
etc.

The "data worksheet" will be updated monthly and the number of rows will
vary each time the report is run.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default Exporting data from MS-Access to Excel

Thanks,

I am familiar with sub-totals and will give the code a try. Yes, I am trying
to run this from Access - But it occurred to me that it might be easier to
run it from Excel.


"ryguy7272" wrote in message
...
Do you know how to subtotal in Excel? If so, turn on the macro recorder,
then go through the steps in Excel. Turn off the macro recorder when you
are
done. Take that code and pop it in to this macro (which must be run from
Access):

Option Compare Database



Option Explicit ' Use this to make sure your variables are defined



' One way to be able to use these objects throughout the Module is to
Declare them here, and not in a Sub



Private objExcel As Excel.Application

Private xlWB As Excel.Workbook

Private xlWS As Excel.Worksheet





Sub Rep()



Dim strFile As String



strFile = "C:\path-to-your-file.xls"



'Of course, this is just an example; put the actual path to your actual
file
here.

' Opens Excel and makes it Visible



Set objExcel = New Excel.Application



objExcel.Visible = True



' Opens up a Workbook



Set xlWB = objExcel.Workbooks.Open(strFile)







' Sets the Workseet to the last active sheet - Better to use the commented
version and use the name of the sheet.



Set xlWS = xlWB.ActiveSheet



' Set xlWS = xlWB("Sheet1")





With xlWS ' You are now working with the Named file and the named
worksheet

' Your Excel code begins here.put your subtotaling Excel Macro right
here!!



End With



' Close and Cleanup



xlWB.SaveAs xlSaveFile

xlWB.Close



xlapp.Quit

Set xlapp = Nothing



End Sub

You are trying to control Excel from Access, right. That's how I
interpreted your post. Again, this code is in Access; it needs to be run
from Access.

Regards,
Ryan---


--
RyGuy


"JimP" wrote:

...need some help (a reference, or book, that will explain how to export
data
from Access to Excel) to create a formatted report with sub-totals.

e.g. this is an employee timesheet application that will export data from
an
Access query into what must eventually be a report with department and
employee groupings and sub-totals of hours, with drill down on the
sub-totals.

I know how to do the "TransferSpreadsheet" method to get the data into
Excel, but how do I get it into a usable form once it is in Excel.

My guess is it must go into a "data worksheet" which then loads into a
separate "report worksheet", with column headers, sub-totals, formatting
etc.

The "data worksheet" will be updated monthly and the number of rows will
vary each time the report is run.





  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default Exporting data from MS-Access to Excel

One question though.

It looks like this code will start my data range in cell A:1 in the named
worksheet. What if I have report and column headers already set up on the
named worksheet. Is there a way to start my exported data range in a cell
other than A:1?


"ryguy7272" wrote in message
...
Do you know how to subtotal in Excel? If so, turn on the macro recorder,
then go through the steps in Excel. Turn off the macro recorder when you
are
done. Take that code and pop it in to this macro (which must be run from
Access):

Option Compare Database



Option Explicit ' Use this to make sure your variables are defined



' One way to be able to use these objects throughout the Module is to
Declare them here, and not in a Sub



Private objExcel As Excel.Application

Private xlWB As Excel.Workbook

Private xlWS As Excel.Worksheet





Sub Rep()



Dim strFile As String



strFile = "C:\path-to-your-file.xls"



'Of course, this is just an example; put the actual path to your actual
file
here.

' Opens Excel and makes it Visible



Set objExcel = New Excel.Application



objExcel.Visible = True



' Opens up a Workbook



Set xlWB = objExcel.Workbooks.Open(strFile)







' Sets the Workseet to the last active sheet - Better to use the commented
version and use the name of the sheet.



Set xlWS = xlWB.ActiveSheet



' Set xlWS = xlWB("Sheet1")





With xlWS ' You are now working with the Named file and the named
worksheet

' Your Excel code begins here.put your subtotaling Excel Macro right
here!!



End With



' Close and Cleanup



xlWB.SaveAs xlSaveFile

xlWB.Close



xlapp.Quit

Set xlapp = Nothing



End Sub

You are trying to control Excel from Access, right. That's how I
interpreted your post. Again, this code is in Access; it needs to be run
from Access.

Regards,
Ryan---


--
RyGuy


"JimP" wrote:

...need some help (a reference, or book, that will explain how to export
data
from Access to Excel) to create a formatted report with sub-totals.

e.g. this is an employee timesheet application that will export data from
an
Access query into what must eventually be a report with department and
employee groupings and sub-totals of hours, with drill down on the
sub-totals.

I know how to do the "TransferSpreadsheet" method to get the data into
Excel, but how do I get it into a usable form once it is in Excel.

My guess is it must go into a "data worksheet" which then loads into a
separate "report worksheet", with column headers, sub-totals, formatting
etc.

The "data worksheet" will be updated monthly and the number of rows will
vary each time the report is run.





  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,836
Default Exporting data from MS-Access to Excel

Sure, set it up in Excel, then copy/paste your Excel code right below this
line and run your Access macro. You will be amazed when you see what
happens. Just try it and you'll see.

One more thing, set a reference to Excel in Access.
Alt + F11 Tools References Microsoft Excel xx.x Object Library

Regards,
Ryan---

--
RyGuy


"JimP" wrote:

One question though.

It looks like this code will start my data range in cell A:1 in the named
worksheet. What if I have report and column headers already set up on the
named worksheet. Is there a way to start my exported data range in a cell
other than A:1?


"ryguy7272" wrote in message
...
Do you know how to subtotal in Excel? If so, turn on the macro recorder,
then go through the steps in Excel. Turn off the macro recorder when you
are
done. Take that code and pop it in to this macro (which must be run from
Access):

Option Compare Database



Option Explicit ' Use this to make sure your variables are defined



' One way to be able to use these objects throughout the Module is to
Declare them here, and not in a Sub



Private objExcel As Excel.Application

Private xlWB As Excel.Workbook

Private xlWS As Excel.Worksheet





Sub Rep()



Dim strFile As String



strFile = "C:\path-to-your-file.xls"



'Of course, this is just an example; put the actual path to your actual
file
here.

' Opens Excel and makes it Visible



Set objExcel = New Excel.Application



objExcel.Visible = True



' Opens up a Workbook



Set xlWB = objExcel.Workbooks.Open(strFile)







' Sets the Workseet to the last active sheet - Better to use the commented
version and use the name of the sheet.



Set xlWS = xlWB.ActiveSheet



' Set xlWS = xlWB("Sheet1")





With xlWS ' You are now working with the Named file and the named
worksheet

' Your Excel code begins here.put your subtotaling Excel Macro right
here!!



End With



' Close and Cleanup



xlWB.SaveAs xlSaveFile

xlWB.Close



xlapp.Quit

Set xlapp = Nothing



End Sub

You are trying to control Excel from Access, right. That's how I
interpreted your post. Again, this code is in Access; it needs to be run
from Access.

Regards,
Ryan---


--
RyGuy


"JimP" wrote:

...need some help (a reference, or book, that will explain how to export
data
from Access to Excel) to create a formatted report with sub-totals.

e.g. this is an employee timesheet application that will export data from
an
Access query into what must eventually be a report with department and
employee groupings and sub-totals of hours, with drill down on the
sub-totals.

I know how to do the "TransferSpreadsheet" method to get the data into
Excel, but how do I get it into a usable form once it is in Excel.

My guess is it must go into a "data worksheet" which then loads into a
separate "report worksheet", with column headers, sub-totals, formatting
etc.

The "data worksheet" will be updated monthly and the number of rows will
vary each time the report is run.






Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Exporting Data from MS-Access to Excel JimP Excel Programming 2 March 9th 09 12:49 PM
Exporting data range from Excel to Access Shep Excel Programming 3 February 5th 07 05:10 PM
exporting data from access to excel [email protected] Excel Discussion (Misc queries) 1 April 11th 06 10:17 AM
Exporting data from access to excel vinayak Excel Worksheet Functions 0 April 11th 06 08:20 AM


All times are GMT +1. The time now is 11:35 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"