Hi my code does exactly what I want it to do except I cannot get the excel instance to close, I know its my coding but I have no clue where I am going wrong.
please could someone help me, many thanks in advance
my code does the following, user selects excel file, opens it, renames sheets, basically needs first sheet to be sheet1. rest don't matter
Changes the formats in column a to number and 15dp, saves the file as .xls and then links the file to the database.
please could someone help me, many thanks in advance
my code does the following, user selects excel file, opens it, renames sheets, basically needs first sheet to be sheet1. rest don't matter
Changes the formats in column a to number and 15dp, saves the file as .xls and then links the file to the database.
Code:
Private Sub Command288_Click()
Dim s As String
Dim i As Long
Dim ExcelWorkbook As Excel.Workbook
s = LaunchCD(Me)
Dim XLApp As Object
Set XLApp = CreateObject("Excel.Application")
XLApp.Visible = False
Set ExcelWorkbook = XLApp.Workbooks.Open(s)
With ExcelWorkbook
For i = 1 To ExcelWorkbook.Sheets.Count
ExcelWorkbook.Sheets(i).Name = "Sheet" & i & ""
Next
End With
ExcelWorkbook.Sheets(1).Columns("A:A").Select
Selection.NumberFormat = "0.000000000000000"
ExcelWorkbook.SaveAs Left(s, InStrRev(s, ".") - 1) & ".xls", FileFormat:=xlNormal
ExcelWorkbook.Close
Set ExcelWorkbook = Nothing
XLApp.Quit
Set XLApp = Nothing
DoCmd.TransferSpreadsheet acLink, , "Sheet1", Left(s, InStrRev(s, ".") - 1) & ".xls", True, "Sheet1!A14:C43"
DoCmd.OpenForm ("frmList1")
Forms![frmList1]![Text0] = Left(s, InStrRev(s, ".") - 1) & ".xls"