Bonjour,
J'ai créé une macro qui me permet à partir d'un tableau excel, de créer un fichier texte que j'upload ensuite sur un serveur.
Le problème est que que pour chaque ligne que je crée, Excel me rajoute des guillemets en début et fin de ligne.
Je pense que c'est le délimiteur par défaut des cellules Excel.
Y a-t-il une possibilité de l'enlever ?
Voici ma macro:
Merci d'avance pour toute aide.
J'ai créé une macro qui me permet à partir d'un tableau excel, de créer un fichier texte que j'upload ensuite sur un serveur.
Le problème est que que pour chaque ligne que je crée, Excel me rajoute des guillemets en début et fin de ligne.
Je pense que c'est le délimiteur par défaut des cellules Excel.
Y a-t-il une possibilité de l'enlever ?
Voici ma macro:
Code:
Sub auto_open()
Workbooks.Open Filename:="C:\XETRA\DAX\DAX_Weighting_File.xls"
Dim i As Integer
Dim j As Integer
Dim k As Integer
Dim l As String
Dim m As Integer
Dim n As Integer
Dim p As Integer
Dim q As Integer
Dim r As Integer
Dim s As Integer
Dim t As Integer
Dim mnemo As String
Dim isin As String
Dim libelle As String
Dim complibelle As String
Dim coef As String
Dim coef_dax As String
Dim compcoef As String
Dim clot As String
Dim clot1 As String
Dim clot2 As String
Dim compclot As String
Dim srcSheet As Worksheet
Windows("index_dta.xls").Activate
Workbooks("index_dta.xls").Worksheets("Sheet1").Cells(1, 1).Value = " mnemo (m) isin (m) libelle (f) coef (m) close (f)"
Workbooks("index_dta.xls").Worksheets("Sheet1").Cells(2, 1).Value = "- ------------ ------------ ---------------------- ---------- -----------"
i = 9
j = 3
Set srcSheet = Workbooks("DAX_Weighting_File.xls").Worksheets("Data for next day")
'recuperation mnemo
Do
k = Len(srcSheet.Cells(i, 2))
If k = 3 Then
mnemo = srcSheet.Cells(i, 2).Value & " "
Else
mnemo = srcSheet.Cells(i, 2).Value & " "
End If
'recuperation isin
isin = srcSheet.Cells(i, 4).Value & " "
'recuperation libelle
l = 23 - Len(srcSheet.Cells(i, 3))
libelle = srcSheet.Cells(i, 3).Value
If l > 0 Then
For n = 1 To l
libelle = libelle & " "
Next n
End If
If Len(srcSheet.Cells(i, 3)) > 23 Then
libelle = Left(srcSheet.Cells(i, 3), 23)
End If
'recuperation coef
coef = srcSheet.Cells(i, 13).Value
If Len(srcSheet.Cells(i, 13)) = 8 Then
coef = srcSheet.Cells(i, 13).Value & " * "
Else
coef = srcSheet.Cells(i, 13).Value & " "
End If
If Len(srcSheet.Cells(i, 13)) = 7 Then
coef = "0" & srcSheet.Cells(i, 13).Value & " * "
End If
If Len(srcSheet.Cells(i, 13)) = 6 Then
coef = "0" & srcSheet.Cells(i, 13).Value & "0 * "
End If
'recuperation clot
clot = srcSheet.Cells(i, 7).Value
cloteclat = Split(srcSheet.Cells(i, 7).Value, ".")
clot1 = cloteclat(0)
If InStr(1, srcSheet.Cells(i, 7).Value, ".") = 0 Then
clot2 = "0"
Else
clot2 = cloteclat(1)
End If
m = Len(clot1)
If m > 0 Then
For p = m To 6
clot1 = "0" & clot1
Next p
End If
q = Len(clot2)
If q < 3 Then
For r = q To 3
clot2 = clot2 & "0"
Next r
End If
clot = Left(clot1 & "." & clot2, 11)
Workbooks("index_dta.xls").Worksheets("Sheet1").Cells(j, 1).Value = "A " & mnemo & isin & libelle & " " & coef & clot
j = j + 1
i = i + 1
Loop While i < 39
coef_dax = srcSheet.Cells(42, 8).Value
s = Len(srcSheet.Cells(42, 8).Value)
If s < 8 Then
For t = s To 8
coef_dax = coef_dax & "0"
Next t
End If
Workbooks("index_dta.xls").Worksheets("Sheet1").Cells(j, 1).Value = "I DAX DE0008469008 DAX (PERFORMANCEINDEX) " & Left(coef_dax, 8) & " * " & "000" & srcSheet.Cells(42, 9).Value & "0"
Sheets(1).Select
Workbooks("index_dta.xls").SaveAs Filename:= _
"C:\tmp\index.dta", FileFormat:=xlUnicodeText, _
CreateBackup:=False
End Sub
Merci d'avance pour toute aide.