Solved

Open excel file after being created by Access

Posted on 2016-11-13
3
31 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 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 49

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

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

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

QuickBooks® has a great invoice interface that we were happy with for a while but that changed in 2001 through no fault of Intuit®. Our industry's unit names are dictated by RUS: the Rural Utilities Services division of USDA. Contracts contain un…
Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

777 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