Bonjour à tous,
J'ai changé ce programme ci qui fonctionne:
Par celui-ci qui indique un message d'erreur 1004 (voir pièces jointes). Les changements effectués sont une macro d'appel (macro3) et ce qui est en orange dans la macro "import". Le but de cette modif est de pouvoir importer différents fichiers sources via la variables my_file.Code:
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 Sub Macro1() ' ' Macro1 Macro ' ' With ActiveSheet.QueryTables.Add(Connection:= _ "TEXT;\\10.57.70.210\Production\Secondaire\01-01-2009.his", Destination:= _ Range("$A$3")) .Name = "01-01-2009" .FieldNames = True .RowNumbers = False .FillAdjacentFormulas = False .PreserveFormatting = True .RefreshOnFileOpen = False .RefreshStyle = xlInsertDeleteCells .SavePassword = False .SaveData = True .AdjustColumnWidth = True .RefreshPeriod = 0 .TextFilePromptOnRefresh = False .TextFilePlatform = 850 .TextFileStartRow = 1 .TextFileParseType = xlDelimited .TextFileTextQualifier = xlTextQualifierDoubleQuote .TextFileConsecutiveDelimiter = False .TextFileTabDelimiter = False .TextFileSemicolonDelimiter = True .TextFileCommaDelimiter = False .TextFileSpaceDelimiter = False .TextFileColumnDataTypes = Array(1, 1, 1, 1, 1, 1, 1) .TextFileTrailingMinusNumbers = True .Refresh BackgroundQuery:=False End With End Sub
QQn sait-il de quoi vient ce message d'erreur?Code:
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 Sub Macro3() ' ' Macro3 Macro ' ' Dim my_file As String my_file = "01-01-2009" Call import End Sub Public Sub import() Range("A3").Select With ActiveSheet.QueryTables.Add(Connection:= _ "TEXT;\\10.57.70.210\Production\Secondaire\" & my_file & ".his", Destination:= _ Range("$A$3")) .Name = my_file .FieldNames = True .RowNumbers = False .FillAdjacentFormulas = False .PreserveFormatting = True .RefreshOnFileOpen = False .RefreshStyle = xlInsertDeleteCells .SavePassword = False .SaveData = True .AdjustColumnWidth = True .RefreshPeriod = 0 .TextFilePromptOnRefresh = False .TextFilePlatform = 850 .TextFileStartRow = 1 .TextFileParseType = xlDelimited .TextFileTextQualifier = xlTextQualifierDoubleQuote .TextFileConsecutiveDelimiter = False .TextFileTabDelimiter = False .TextFileSemicolonDelimiter = True .TextFileCommaDelimiter = False .TextFileSpaceDelimiter = False .TextFileColumnDataTypes = Array(1, 1, 1, 1, 1, 1, 1) .TextFileTrailingMinusNumbers = True .Refresh BackgroundQuery:=False End With End Sub
Merci