Connecting Tech Pros Worldwide Help | Site Map

Exporting to excel

 
LinkBack Thread Tools Search this Thread
  #1  
Old July 18th, 2006, 04:55 AM
Gregc.
Guest
 
Posts: n/a
Default Exporting to excel

Hi

I'm trying to download a query into excel and opening it up as a pivot
table. Firstly, is this possible? This is my code thus far:

Function Export()
Dim excel As String
excel = "CONSOLIDATION_XTRACT_TOTAL"
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, excel,
"C:\Documents and Settings\GregoryCh\My Documents\Test.xls"

End Function

Greg


  #2  
Old July 18th, 2006, 06:15 AM
pietlinden@hotmail.com
Guest
 
Posts: n/a
Default Re: Exporting to excel

You could record a macro in Excel that creates the pivot table, and
then call it using automation after you transfer the data.

  #3  
Old July 18th, 2006, 08:35 AM
Gregc.
Guest
 
Posts: n/a
Default Re: Exporting to excel


pietlinden@hotmail.com wrote:
Quote:
You could record a macro in Excel that creates the pivot table, and
then call it using automation after you transfer the data.
I'm trying to automate the process.

Greg

  #4  
Old July 18th, 2006, 12:45 PM
Ron2006
Guest
 
Posts: n/a
Default Re: Exporting to excel

I know I did that a while back. I believe what I did was downloaded the
data, then from access, opened the spreadsheet, whent to the pivot
table tab, and issued a refresh.

I believe I made a macro in excell to show me the steps needed and then
duplicated these instructions from within Access.

Ron

  #5  
Old July 19th, 2006, 12:15 AM
Gregc.
Guest
 
Posts: n/a
Default Re: Exporting to excel


Ron2006 wrote:
Quote:
I know I did that a while back. I believe what I did was downloaded the
data, then from access, opened the spreadsheet, whent to the pivot
table tab, and issued a refresh.
>
I believe I made a macro in excell to show me the steps needed and then
duplicated these instructions from within Access.
>
Ron
Well this is where I am at.

Function TsfrExcel()
Dim objXL As Object
Dim excel As String
Dim strFile As String

excel = "CONSOLIDATION_XTRACT_TOTAL"
strFile = "C:\Documents and Settings\gregorych\My
Documents\Test.xls"
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, excel,
"C:\Documents and Settings\GregoryCh\My Documents\Test.xls"
Set objXL = CreateObject("Excel.Application")
With objXL.Application
.Visible = True
.Workbooks.Open strFile

objXL.ActiveWorkbook.PivotCaches.Add(SourceType:=x lDatabase,
SourceData:= _
"CONSOLIDATION_XTRACT_TOTAL!C1:C7").CreatePivotTab le
TableDestination:="", _
TableName:="PivotTable3", DefaultVersion:=xlPivotTableVersion10
objXL.ActiveSheet.PivotTableWizard
TableDestination:=ActiveSheet.Cells(3, 1)
objXL.ActiveSheet.Cells(3, 1).Select
objXL.ActiveSheet.PivotTables("PivotTable3").AddFi elds
RowFields:=Array( _
"Fund_Type_2", "Fund_Type", "Expenditure_Type"),
ColumnFields:="Sub Hierarchy"
With
objXL.ActiveSheet.PivotTables("PivotTable3").Pivot Fields("SumOfTotal_Budget")
.Orientation = xlDataField
.Caption = "Sum of SumOfTotal_Budget"
.Function = xlSum
End With
objXL.ActiveSheet.PivotTables("PivotTable3").Pivot Select "YHR",
xlDataAndLabel, True
With obj.Xl.ActiveSheet.PivotTables("PivotTable3").Pivo tFields("Sub
Hierarchy")
.PivotItems("(blank)").Visible = False
End With
Set objXL = Nothing
End With

End Function

At the moment I am stuck here:
objXL.ActiveWorkbook.PivotCaches.Add(SourceType:=x lDatabase,
SourceData:= _
"CONSOLIDATION_XTRACT_TOTAL!C1:C7").CreatePivotTab le
TableDestination:="", _
TableName:="PivotTable3", DefaultVersion:=xlPivotTableVersion10

Greg

 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,662 network members.