Solved

Open excel file after being created by Access

Posted on 2016-11-13
3
40 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 500 total points
ID: 41885369
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel12Xml, "QryEbill", "C:\Documents\myexcel.xlsx", True
 
FollowHyperlink "C:\Documents\myexcel.xlsx"
0
 
LVL 50

Expert Comment

by:Gustav Brock
ID: 41885370
You can use OutPutTo with the magic True:

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

/gustav
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 41885371
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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

740 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