I use the VBA below to open an Excel workbook.
It opens and I close it again manually. The Excel window also closes.
If I try the process again, It does not open.
If I look on windows taskmanager, I see there is an Excel instance under processes. If I close that, the VBA works again one time.
My code is:
Private Sub cmdOpenExcelWorkbook_Click()
' Open Excel Workbook
Dim excelApp As Excel.Application
Dim wb As Excel.Workbook
Dim WorkbookToOpen As String
WorkbookToOpen = Me.txtOrigATD 'A textbox on my form
Set excelApp = CreateObject("Excel.Application")
Set wb = Excel.Workbooks.Open(WorkbookToOpen)
excelApp.Visible = True
' wb.ActiveSheet.Range("d1").Value = 100 'Passes a value to a cell on the spreadsheet.
Set excelApp = Nothing
Set wb = Nothing