Open Excel doc from Access

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi. I'm trying to export data from Access to Excel, and then open the
spreadsheet automatically for the user. I've got the data exported just fine,
but can't get it to open. Here's the relevant code:

Set e = New Excel.Application
Set w = e.Workbooks.Open(strPath & strFile)
With w.NewWindow()
.Activate
.WindowState = Excel.XlWindowState.xlMaximized
End With

I'm not getting any error messages. The objects are being created, and are
visible in the locals window during run-time. Each time I run the code, a new
instance of Excel opens in the background. How do I get it to appear onscreen?
 
Hi Mike

You need to use the Visible property of the Excel.Application:
e.Visible = True

No need for the .NewWindow method - that will just open a second window on
the workbook.
 
Excellent. Thanks Graham.




Graham Mandeno said:
Hi Mike

You need to use the Visible property of the Excel.Application:
e.Visible = True

No need for the .NewWindow method - that will just open a second window on
the workbook.

--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand

mike said:
Hi. I'm trying to export data from Access to Excel, and then open the
spreadsheet automatically for the user. I've got the data exported just
fine,
but can't get it to open. Here's the relevant code:

Set e = New Excel.Application
Set w = e.Workbooks.Open(strPath & strFile)
With w.NewWindow()
.Activate
.WindowState = Excel.XlWindowState.xlMaximized
End With

I'm not getting any error messages. The objects are being created, and are
visible in the locals window during run-time. Each time I run the code, a
new
instance of Excel opens in the background. How do I get it to appear
onscreen?
 
Back
Top