-
Notifications
You must be signed in to change notification settings - Fork 11
/
Excel VBA - XML2.vb
61 lines (40 loc) · 1.43 KB
/
Excel VBA - XML2.vb
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
Option Explicit
Dim titles_Dic As Scripting.Dictionary
Sub opening_Uploading_File()
Dim fso As FileSystemObject
Dim file_Folder As Folder
Dim file_Files As file
Dim file_Path As String
file_Path = "C:\Users\Zadig\Documents\Access Databases\"
Set fso = New FileSystemObject
Set file_Folder = fso.GetFolder(file_Path)
'Set file_Files = file_Folder.Files("Import.xlsx")
Set titles_Dic = New Scripting.Dictionary
Dim number_OfFiles As Long
number_OfFiles = file_Folder.Files.Count
'For Each n In file_Folder.Files
'Next
Dim i, r As Long
Dim n, j, file_Type(0), file_Name_Array(0), file_Name, file_Extension As Variant
For Each j In file_Folder.Files
file_Type(0) = Split(j, ".")
file_Extension = file_Type(0)(1)
If file_Extension = "xlsx" Then
file_Name_Array(0) = Split(j, "\")
file_Name = file_Name_Array(0)(5)
r = r + 1
If r > 1 Then
'TO DO
End If
End If
Next
Set file_Files = file_Folder.Files(file_Name)
set_Dictionnary "Title A", 1
set_Dictionnary "Title B", 2
Set fso = Nothing
Set file_Folder = Nothing
Set file_Files = Nothing
End Sub
Private Sub set_Dictionnary(ByVal t As String, ByVal element_Key As Long)
titles_Dic.Add element_Key, t
End Sub