mattewsearle79
New member
- Local time
- Today, 12:28
- Joined
- Sep 29, 2016
- Messages
- 2
Hi
I'm relatively new to using VBA. I've put in the below code to open an excel spreadsheet from access but when I press the button the spreadsheet opens in the background rather than in front of access. How can I open the spreadsheet in the foreground? Please be gentle and explain where I would need to add to the code.
Private Sub Command0_Click()
Dim xlApp As Excel.Application
Dim xlWB As Excel.Workbook
Set xlApp = New Excel.Application
With xlApp
.UserControl = True
.Visible = True
.WindowState = Excel.XlWindowState.xlMaximized
Set xlWB = .Workbooks.Open("C:\Users\Public\Documents\Rota.xlsx", , False)
End With
End Sub
Thanks in advance.
I'm relatively new to using VBA. I've put in the below code to open an excel spreadsheet from access but when I press the button the spreadsheet opens in the background rather than in front of access. How can I open the spreadsheet in the foreground? Please be gentle and explain where I would need to add to the code.
Private Sub Command0_Click()
Dim xlApp As Excel.Application
Dim xlWB As Excel.Workbook
Set xlApp = New Excel.Application
With xlApp
.UserControl = True
.Visible = True
.WindowState = Excel.XlWindowState.xlMaximized
Set xlWB = .Workbooks.Open("C:\Users\Public\Documents\Rota.xlsx", , False)
End With
End Sub
Thanks in advance.