1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
| Private Sub bout_ouvre_enco_vrco_Click()
Dim xlApp As Excel.Application
Dim xlSheet As Excel.Worksheet
Dim xlBook As Excel.Workbook
Dim test As String
Dim MyQuery As String
On Error GoTo Error_encodage
Set xlApp = CreateObject("Excel.Application")
Set xlBook = xlApp.Workbooks.Open("O:\bdcreuset1.1\export_v1-3.xls")
Set xlSheet = xlBook.Worksheets("Sheet1")
MsgBox ("fin sheet")
MyQuery = "INSERT INTO melting_program (file_name, requester, glass_project, program_objective, crucible_type, furnace_number, atmosphere, account, week, nbre_coulees, comment) Values "
MsgBox ("5.6 =" & xlSheet.Cells(5, 6))
MyQuery = MyQuery & "(" & Chr(34) & xlSheet.Cells(5, 6) & Chr(34) & ", " & Chr(34) & xlSheet.Cells(4, 6) & Chr(34) & ", " & Chr(34) & xlSheet.Cells(3, 2) & Chr(34) & ", " & Chr(34) & xlSheet.Cells(4, 2) & Chr(34) & ", " & Chr(34) & xlSheet.Cells(5, 2) & Chr(34) & ", " & xlSheet.Cells(9, 2) & ", " & Chr(34) & xlSheet.Cells(10, 2) & Chr(34) & ", " & Chr(34) & xlSheet.Cells(7, 2) & Chr(34) & ", " & Chr(34) & xlSheet.Cells(8, 2) & Chr(34) & ", " & xlSheet.Cells(6, 2) & ", " & Chr(34) & xlSheet.Cells(9, 6) & Chr(34) & ")"
MsgBox ("query = " & MyQuery)
DoCmd.RunSQL MyQuery
MsgBox ("ok")
xlApp.Quit
Set xlSheet = Nothing
Set xlBook = Nothing
Set xlApp = Nothing
Exit Sub
Error_encodage:
MsgBox Error$
Set xlSheet = Nothing
Set xlBook = Nothing
xlApp.Quit
Set xlApp = Nothing
Exit Sub
End Sub |
Partager