I create an Excel spreadsheet in VBA in Access the start of which is:
' Dim excelobj As Excel.Application
Dim excelobj As Object
Set excelobj = openExcel
With excelobj
.Workbooks.Add
.Visible = True
.ActiveWorkbook.Sheets(1).Select
.ActiveSheet.Name = "Invoice schedule"
.cells(1, 1).FormulaR1C1 = "Invoice Schedule Week Ending " & Format(Me.fromDate, "dd/mm/yyyy") .cells(1, 1).Font.Bold = True
.cells(2, 1) = "Vehicle"
.cells(2, 2) = "Date"
.cells(2, 3) = "Contract number"
.cells(2, 4) = "Client"
All this works well. However I would like the Excel window to become the foreground window. How do I do this?
DoCmd.SelectObject does not handle this.
I create an Excel spreadsheet in VBA in Access the start of which is:
' Dim excelobj As Excel.Application
Dim excelobj As Object
Set excelobj = openExcel
With excelobj
.Workbooks.Add
.Visible = True
.ActiveWorkbook.Sheets(1).Select
.ActiveSheet.Name = "Invoice schedule"
.cells(1, 1).FormulaR1C1 = "Invoice Schedule Week Ending " & Format(Me.fromDate, "dd/mm/yyyy")
.cells(1, 1).Font.Bold = True
.cells(2, 1) = "Vehicle"
.cells(2, 2) = "Date"
.cells(2, 3) = "Contract number"
.cells(2, 4) = "Client"
All this works well. However I would like the Excel window to become the foreground window. How do I do this?
DoCmd.SelectObject does not handle this.
on 11/30/2021, Keith Tizzard supposed :
I create an Excel spreadsheet in VBA in Access the start of which is:
' Dim excelobj As Excel.Application
Dim excelobj As Object
Set excelobj = openExcel
With excelobj
.Workbooks.Add
.Visible = True
.ActiveWorkbook.Sheets(1).Select
.ActiveSheet.Name = "Invoice schedule"
.cells(1, 1).FormulaR1C1 = "Invoice Schedule Week Ending " & Format(Me.fromDate, "dd/mm/yyyy") .cells(1, 1).Font.Bold = True
.cells(2, 1) = "Vehicle"
.cells(2, 2) = "Date"
.cells(2, 3) = "Contract number"
.cells(2, 4) = "Client"
All this works well. However I would like the Excel window to become the foreground window. How do I do this?
DoCmd.SelectObject does not handle this.I believe you can use the VBA command AppActivate to do this.
AppActivate Application.Caption
Rdub
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 296 |
Nodes: | 16 (2 / 14) |
Uptime: | 34:39:31 |
Calls: | 6,648 |
Calls today: | 3 |
Files: | 12,193 |
Messages: | 5,328,826 |