Share via

Open close excel using Access 2016

Anonymous
2019-01-26T21:54:50+00:00

I  Access  2007 program that exports data to excel, opens closes the excel file, then imports the calculated results back to Access.  It worked fine until started using  Access 2016.  We had several problems including need to use xlsm instead of xls, but got system working except for the open close excel need.  After export, It must be open/closed for the new results to be imported.

This is open close routine used in access 2007 that works fine:

Dim xl As Excel.Application, WB As Excel.Workbook  '

Set xl = CreateObject("Excel.Application")

Set WB = xl.Workbooks.Open(CurrentProject.Path & "" & .ExcelFile)  ('refers to with  CurrentProjectPath etc.)

WB.close True

xl.Quit

With 2016, the user has to manually open/close the xlsm file to get the results imported. 

Any help mujch apppreciated.  Driving us nut.s.

Microsoft 365 and Office | Access | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

Answer accepted by question author

Anonymous
2019-02-28T00:04:52+00:00

In case anyone needs answer, I found this.  It works in access 2016 and in 2003 and 2007

Dim xlapp As Object 'had to add this.  

Set xlapp = CreateObject("Excel.Application")

xlapp.Visible = False

xlapp.Workbooks.Open exfile, True, False  'true fals remoeved, not effect

xlapp.Quit

Set xlapp = Nothing

Was this answer helpful?

0 comments No comments

0 additional answers

Sort by: Most helpful