Bonjour,
http://www.freevbcode.com/ShowCode.asp?ID=1204
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 Public Function LoadRsFromXML(FullPath As String) As Object '************************************************** 'PURPOSE: LOAD A RECORDSET FROM AN XML FILE USING 'ADO 2.5. THE XML FILE MUST HAVE BEEN SAVED 'USING SAVE METHOD OF RECORDSET OBJECT WITH adPersistXML AD 'SECOND PARAMETER 'PARAMETERS: 'FullPath: FullPath of XMLFile to load 'RETURNS: Reference to a Recordset Object, or Nothing if ' Function fails 'REQUIRES: Installation of and reference to ADO 2.5 'EXAMPLE: See Example for SaveRsToXML '****************************************************** Dim oRs As Object Set oRs = CreateObject("ADODB.Recordset") On Error Resume Next Const adCmdFile = 256 Const adOpenForwardOnly = 0 Const adLockReadOnly = 1 If Dir(FullPath) = "" Then Exit Function oRs.Open FullPath, "Provider=MSPersist;", adOpenForwardOnly, _ adLockReadOnly, adCmdFile If Err.Number = 0 Then Set LoadRsFromXML = oRs End If End Function Sub test() Set a = LoadRsFromXML("C:\Users\Robert\Desktop\Fichier.xml") For i = 0 To a.Fields.Count - 1 Range("A1").Offset(0, i) = a(i).Name Next Range("A2").CopyFromRecordset a End Sub
Partager