Mon application va lire un fichier excel sans l'ouvrir
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questionMon application va lire un fichier excel sans l'ouvrir
Dim Cn1 As ADODB.Connection Set Cn1 = New ADODB.Connection Dim rec1 As ADODB.Recordset Set rec1 = New ADODB.Recordset Dims as string fichierovv 'Init Variable Fichierovv = "C:\Documents and Settings\K005889\Desktop\Current Version\Fichier tests\ LG_PF_OVV_LTRgr1.xlsm" 'Connection to the Excel file as a database With Cn1 .Provider = "Microsoft.Jet.OLEDB.4.0" .ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" _ & fichierovv & ";Extended Properties=""Excel 12.0;HDR=YES;""" .Open End With 'We copy the content from the Excel file into the recordset (where "NomFeuilleovv" is the name of the sheet in the open workbook) rec1.Open "SELECT * FROM [" & NomFeuilleovv & "$]", Cn1, adOpenKeyset, adLockOptimistic rec1.MoveFirst 'We look for the line where the item in column "Objective Id" equals NSS-FOD-PF-OVV-FU-472 rec1.Find "[Objective Id]= 'NSS-FOD-PF-OVV-FU-472'", , adSearchForward 'We get description of the Objective objdesc = rec1![Objective Description] 'We get comment of the Objective comment = rec1![Comment and additional information]