Solved

Open excel file after being created by Access

Posted on 2016-11-13
3
20 Views
Last Modified: 2016-11-13
I would like to automatically open the resulting Excel File after this code runs with my Access 2013 Database.

Private Sub Command60_Click()

 

 DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel12Xml, "QryEbill", "C:\Documents\myexcel.xlsx", True

 End Sub
0
Comment
Question by:seamus9909
  • 2
3 Comments
 
LVL 119

Accepted Solution

by:
Rey Obrero earned 500 total points
Comment Utility
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel12Xml, "QryEbill", "C:\Documents\myexcel.xlsx", True
 
FollowHyperlink "C:\Documents\myexcel.xlsx"
0
 
LVL 49

Expert Comment

by:Gustav Brock
Comment Utility
You can use OutPutTo with the magic True:

    DoCmd.OutputTo acOutputQuery, "QryEbill", acFormatXlsx, "C:\Documents\myexcel.xlsx", True

/gustav
0
 
LVL 119

Expert Comment

by:Rey Obrero
Comment Utility
or

 DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel12Xml, "QryEbill", "C:\Documents\myexcel.xlsx", True
 
 'check if the file was created
 If Dir("C:\Documents\myexcel.xlsx") <> "" Then
    FollowHyperlink "C:\Documents\myexcel.xlsx"
 End If
0

Featured Post

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Join & Write a Comment

Most if not all databases provide tools to filter data; even simple mail-merge programs might offer basic filtering capabilities. This is so important that, although Access has many built-in features to help the user in this task, developers often n…
I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now