Results 1 to 2 of 2
  1. #1
    deepanadhi is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    May 2012
    Posts
    22

    Export Queries to Excel tabs with Save as Dialog box

    Hi,

    I have to export 4 queries into 4 sheets of single excel file. I dont want the file path to be hard coded, instead user should be able to select the file location unsing Save Dialog box. My Code works fine for getting 4 sheets into Excel sheet well. Also please check in the following code, that where should i add code to format the Excel sheet, i,e Font, color, Bold etc plz give sample code for that.



    What changes and additions shud be made inthe following code. Thanks in Advance.

    Code:
    Private Sub Command42_Click()
    Dim fDialog As Object
    Dim varFile As Variant
    Set fDialog = Application.FileDialog(MsoFileDialogType)
    With fDialog
    .AllowMultiSelect = False
    .Title = "Select File Location to Export XLSx :"
    .InitialFileName = "DN.xlsx"
    If .Show = True Then
    For Each varFile In .SelectedItems
    getFileName = varFile
    Next
    End If
    End With
    On Error GoTo Do_Nothing
     
        DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, "qry_apcc", "C:\Users\Public\Documents\Discp_ASN.xls", True, "D"
        DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, "qry_asn", "C:\Users\Public\Documents\Discp_ASN.xls", True, "AN"
        DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, "qry_apcc_part", "C:\Users\Public\Documents\Discp_ASN.xls", True, "Pal"
        DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, "qry_apcc_cfg", "C:\Users\Public\Documents\Discp_ASN.xls", True, "Cal"
        
        MsgBox "The tables have been successfully exported"
    Exit Sub
    Do_Nothing:
        MsgBox "Export has failed.  An error occurred or the user terminated the operation."
        
    End Sub
    Thanks.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    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. Export Filtered Results to Excel Tabs
    By opod in forum Programming
    Replies: 1
    Last Post: 08-03-2011, 01:33 PM
  2. Replies: 1
    Last Post: 04-17-2011, 04:16 PM
  3. Save As Dialog Box for Reports
    By eww in forum Programming
    Replies: 1
    Last Post: 12-01-2010, 03:12 PM
  4. Multiple Queries to excel with Save As...
    By BED in forum Import/Export Data
    Replies: 7
    Last Post: 12-01-2010, 11:55 AM
  5. Replies: 1
    Last Post: 05-28-2009, 05:08 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