Open Excel doc from Access

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?
 
G

Graham Mandeno

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.
 
G

Guest

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?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top