I am importing Excel data into Access.
I have code already writen that pulls the sheet names from user selected excel files, populates a form with the sheet names(opens files to get names and closes), allows the user to chose with Sheets to import, and then imports those sheets(opens and reformats sheets if needed then closes). The issue I have is that I am opening and closeing the Excel file 2 times during this process.
I would like to open the workbook and then be able to reselect the workbook later but am having difficulty in getting the code correct in Access.
Heres a snippet of code where the file is opened for the second time where I would like to just activate the file instead.
Help?
I have code already writen that pulls the sheet names from user selected excel files, populates a form with the sheet names(opens files to get names and closes), allows the user to chose with Sheets to import, and then imports those sheets(opens and reformats sheets if needed then closes). The issue I have is that I am opening and closeing the Excel file 2 times during this process.
I would like to open the workbook and then be able to reselect the workbook later but am having difficulty in getting the code correct in Access.
Heres a snippet of code where the file is opened for the second time where I would like to just activate the file instead.
Help?
Code:
Public Sub FormatExcelSheet()
' removes excess row data from spreadsheet
Dim AppExcel As Object
Set AppExcel = CreateObject("Excel.Application")
Dim ColDel As Integer
AppExcel.workbooks.Open FileNameO
AppExcel.Visible = False
' AppExcel.Visible = True
AppExcel.sheets(WSOrderName).Activate
rownumber = AppExcel.ActiveSheet.UsedRange.columns.Count
AppExcel.columns(1).select
Do
If AppExcel.activecell.Value <> "" Then
AppExcel.activecell.offset(0, 1).select
End If
Loop Until AppExcel.activecell = ""