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 37 38 39 40 41 42
| Private Sub Command0_Click()
Me!Text1 = LaunchCD(Me) 'Séléction du fichier
End Sub
Private Sub open_Click()
Dim OpiXls As Excel.Application
Dim OpiBook As Excel.Workbook
Dim OpiSheet As Excel.Worksheet
Set OpiXls = New Excel.Application 'ouverture de Excel
OpiXls.Visible = True
Set OpiBook = OpiXls.Workbooks.Open(Text1) 'Ouverture du classeur
OpiBook.Worksheets.Add.Name = "A_export" 'Création de la nouvelle Feuille
OpiBook.Sheets(2).Cells(2, 1).Copy Sheets(1).Cells(1, 1)
OpiBook.Sheets(2).Cells(2, 9).Copy Sheets(1).Cells(1, 2)
OpiBook.Sheets(2).Cells(2, 10).Copy Sheets(1).Cells(1, 3)
OpiBook.Sheets(2).Cells(2, 11).Copy Sheets(1).Cells(1, 4)
OpiBook.Sheets(2).Cells(5, 7).Copy Sheets(1).Cells(1, 5)
OpiBook.Sheets(2).Cells(5, 10).Copy Sheets(1).Cells(1, 6)
OpiBook.Sheets(2).Cells(5, 14).Copy Sheets(1).Cells(1, 7)
OpiBook.Sheets(2).Cells(8, 7).Copy Sheets(1).Cells(1, 8)
OpiBook.Sheets(2).Cells(8, 10).Copy Sheets(1).Cells(1, 9)
OpiBook.Sheets(2).Cells(8, 14).Copy Sheets(1).Cells(1, 10)
Dim Pathfile As String
Dim NameFile As String
Dim CompletPath As String
NameFile = Today + Text2 + ".xls"
Pathfile = "C:\Documents and Settings\ls-immuno\Mes Documents\OPI\"
CompletPath = Pathfile + NameFile
OpiBook.SaveAs FileName:=CompletPath, FileFormat:=xlNormal, CreateBackup:=False 'enregistrement en XLS
OpiBook.Close
DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel9, "RecapDataOpi", _
CompletPath, False, "A_export!" 'Importation des données dans table access
OpiXls.Quit
Set OpiXls = Nothing
Set OpiBook = Nothing
Set OpiSheet = Nothing
Text1 = Nothing
NameFile = ""
Pathfile = ""
DoCmd.Close A_FORM, "ImportData"
DoCmd.OpenForm "ImportData"
End Sub |
Partager