I open an Excel file through Outlook VBA but it is in the background (behind the Outlook application).
I tried AppActivate, but it raises this error:
Invalid procedure call or argument
Public Sub Open_Excel_File()
Dim xExcelFile As String
Dim xExcelApp As Excel.Application
Dim xWb As Excel.Workbook
Dim xWs As Excel.Worksheet
Dim xExcelRange As Excel.Range
xExcelFile = "xxxxx" ' Path to the Excel File
Set xExcelApp = CreateObject("Excel.Application")
Set xWb = xExcelApp.Workbooks.Open(xExcelFile)
Set xWs = xWb.Sheets(1)
xWs.Activate
Set xExcelRange = xWs.Range("A2")
xExcelRange.Activate
xExcelApp.Visible = True
AppActivate xWb.Windows(1).Caption
End Sub