Results 1 to 2 of 2
  1. #1
    sk88 is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Aug 2011
    Posts
    183

    Exporting pivot tables from Access to Excel.

    Hi Everyone,

    I have not solved the problem from my last post. Therefore I am posting again to see if there is anyone out there who would be able to help me.

    I have a code/module which exports the query to excel. I am having trouble in exporting pivot tables. I have created pivot tables based on the query. But when I export using the codes below, it exports only all the data but not the pivot tables that I have created. Therefore, what code should I be adding to the existing code to export the pivot tables to excel as well?


    The codes that I am using for exporting simple query is:

    Public Sub ExportXLS()

    #If Not CC_Debug Then
    On Error GoTo ErrProc
    #End If

    Const cQuery As String = "qryExportMetrics"


    Dim fc As FileChooser
    Dim strFileName As String

    Set fc = New FileChooser
    fc.DialogTitle = "Select file to save"
    fc.OpenTitle = "Save"
    fc.Filter = "Excel Files (*.xls)"
    strFileName = Nz(fc.SaveFile, "")
    Set fc = Nothing

    ' If user selected nothing or canceled, quit
    If Len(strFileName) = 0 Then
    Exit Sub
    ' If file already exists, delete it
    ElseIf Len(Dir(strFileName)) > 0 Then


    Kill strFileName
    End If

    DoCmd.TransferSpreadsheet _
    acExport, _
    acSpreadsheetTypeExcel9, _
    cQuery, _
    strFileName, _
    HasFieldNames:=True


    ExitProc:
    Exit Sub
    ErrProc:
    ErrMsg Err, Err.Description, Err.Source
    Resume ExitProc

    End Sub


    thank you and hope someone will be able to help me.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,815
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Pivot table - access to excel
    By antagonia in forum Access
    Replies: 3
    Last Post: 12-16-2011, 01:57 PM
  2. Export Access '07 Pivot Tbl to Excel'07
    By nagiese in forum Import/Export Data
    Replies: 1
    Last Post: 02-08-2011, 08:19 AM
  3. Pivot tables and charts - Access or Excel
    By kkrishna in forum Access
    Replies: 1
    Last Post: 06-06-2010, 04:52 AM
  4. Export Access Pivot Table to Excel
    By graviz in forum Programming
    Replies: 1
    Last Post: 11-13-2009, 07:30 AM
  5. Replies: 0
    Last Post: 06-24-2009, 03:10 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums