Results 1 to 5 of 5
  1. #1
    casinc815 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Nov 2013
    Location
    Chicago, IL
    Posts
    46

    Question Adding Blank Excel worksheet to Exported report? Can it be done from Access 2007?

    We have an application, in Access 2007, that assists teachers in managing the mountain of assessment/test
    data that they accumulate each week. We have created Access reports to inspect and review the data and


    on each report we have several buttons at the top right corner of the report. One button is to exit the report, another prints, another saves PDF and finally, one button exports the report to Excel.

    Now that the IT team has let the jeannie out o the bottle, the teachers are embracing the technology and
    actually save time and effort in creating their own reports.

    The issue has now come down to automating the export a bit further. Mind you, all works well. The report
    generation in Access and the export to Excel work well. Now, the request is to add blank worksheets to the
    existing export XLS, once it has been created. In other words, export and then add 3 blank worksheets.

    One of our more ambitious teachers stopped by, to ask if it were possible to automate the addition of blank worksheets to an existing export task?

    At the bottom of a worksheet, one sees Sheet1 or the name of the worksheet. The teacher would like
    to have Sheet2, Sheet 3, ...etc added. Yes! She can do it manually, but wanted to know if it can be
    automated. The result of a saved export is only one worksheet on exporting.

    Your thoughts would be appreciated? Remember this is an exported XLS file and there is nothing on the
    worksheet except the data from the report.

    Thanks!

    casinc815

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    I would say export an empty query with 1 field but no field headers.

    Code:
    vFile = "c:\myfile.xls"
    DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, "qsMyQry", vFile, false, "Sheet1"
    DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, "qsMyQry", vFile, false, "Sheet2"
    DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, "qsMyQry", vFile, false, "Sheet3"

  3. #3
    casinc815 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Nov 2013
    Location
    Chicago, IL
    Posts
    46
    Interesting! Thank you for the quick response.

    Will this work if the worksheet name at the bottom is a file name created by Access at the time of exporting?
    So in the workbook, at the bottom of the first worksheet, one would see filename, sheet1, sheet2,sheet3! Is
    that correct?

    I am writing the code as we converse.

    Thanks!

  4. #4
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    yes, i omitted your 1st query...
    DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, "qsMainQry", vFile, true, "TabName"

    As long as you used the same Filename (vFile), and different tabs, they will all go in the same report.

  5. #5
    casinc815 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Nov 2013
    Location
    Chicago, IL
    Posts
    46
    Quote Originally Posted by ranman256 View Post
    yes, i omitted your 1st query...
    DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, "qsMainQry", vFile, true, "TabName"

    As long as you used the same Filename (vFile), and different tabs, they will all go in the same report.
    Thanks! I will let you know how it works out.

    Jim

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

Similar Threads

  1. Replies: 19
    Last Post: 07-29-2013, 09:11 AM
  2. Replies: 7
    Last Post: 04-22-2013, 08:01 AM
  3. Replies: 3
    Last Post: 08-22-2012, 06:28 AM
  4. Replies: 5
    Last Post: 02-24-2012, 11:02 AM
  5. Ms Access 2007 report export to excel 2007
    By Stan2man in forum Access
    Replies: 6
    Last Post: 11-23-2011, 01:24 PM

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