J
John
I'm am stuck on trying to get the instance of Excel that I am using to copy
data over to Access to close once I am done. No matter what I try, when I
look in my Task Manager there is always a hidden copy of Excel running.
Here is my code, any help would be greatly apprechiated.
Sub ImportFile()
'Asks user to select the import file and then uploads the information into
the Import table
Dim MyRS As DAO.Recordset
Dim ExcelFile As String
Dim fd As FileDialog
Dim result As Variant
Set fd = Application.FileDialog(msoFileDialogFilePicker)
'Create Open File window
With fd
.Title = "Select the Import Excel file from Card Services"
.Filters.Add "Excel File", "*.xls"
.FilterIndex = 2
.AllowMultiSelect = False
.InitialFileName = CurrentProject.Path
result = .Show
If (result <> 0) Then
ExcelFile = Trim(.SelectedItems.Item(1))
End If
End With
'Create Excel Application and open Import Excel file
Dim objXL As Excel.Application
'Set objWkb = Workbooks.Open(ExcelFile)
Set objXL = CreateObject("Excel.Application")
objXL.ScreenUpdating = True
objXL.Visible = True
objXL.Workbooks.Open (ExcelFile)
'Transfers Excel data to Access
DoCmd.SetWarnings False
DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel5, "Import",
ExcelFile, True
DoCmd.SetWarnings True
'Close Excel Application
objXL.ActiveWorkbook.Close False
objXL.Quit
Set objXL = Nothing
End Sub
data over to Access to close once I am done. No matter what I try, when I
look in my Task Manager there is always a hidden copy of Excel running.
Here is my code, any help would be greatly apprechiated.
Sub ImportFile()
'Asks user to select the import file and then uploads the information into
the Import table
Dim MyRS As DAO.Recordset
Dim ExcelFile As String
Dim fd As FileDialog
Dim result As Variant
Set fd = Application.FileDialog(msoFileDialogFilePicker)
'Create Open File window
With fd
.Title = "Select the Import Excel file from Card Services"
.Filters.Add "Excel File", "*.xls"
.FilterIndex = 2
.AllowMultiSelect = False
.InitialFileName = CurrentProject.Path
result = .Show
If (result <> 0) Then
ExcelFile = Trim(.SelectedItems.Item(1))
End If
End With
'Create Excel Application and open Import Excel file
Dim objXL As Excel.Application
'Set objWkb = Workbooks.Open(ExcelFile)
Set objXL = CreateObject("Excel.Application")
objXL.ScreenUpdating = True
objXL.Visible = True
objXL.Workbooks.Open (ExcelFile)
'Transfers Excel data to Access
DoCmd.SetWarnings False
DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel5, "Import",
ExcelFile, True
DoCmd.SetWarnings True
'Close Excel Application
objXL.ActiveWorkbook.Close False
objXL.Quit
Set objXL = Nothing
End Sub