OVH Cloud OVH Cloud

Urgent !! aide avec objet excel en VB6

2 réponses
Avatar
Zarf
Voici mon programme.

Public Sub ConvertirEnExcel(fichier As String)
Dim objXL As Object
Screen.MousePointer = 11
Set objXL = CreateObject("Excel.Application")
With objXL
.Visible = True
.workbooks.OpenText FileName:=fichier, Comma:=True
.Application.DisplayAlerts = False
.Columns("A:A").Select
.Selection.NumberFormat = "mm/dd/yy;@"
.Columns("B:E").Select
.Selection.NumberFormat = "0.00"
.Columns("G:G").Select
.Selection.ClearContents
.Range("A1:F65000").Select
.Selection.Sort Key1:=Range("A1"), Order1:=xlAscending,
Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
.ActiveWorkbook.SaveAs FileName:=fichier
.workbooks.Close
.Application.Quit
End With

Screen.MousePointer = 1
End Sub
J'obtiens toujours l'erreur de compilation
procedure sub ou fonction non-défini.
Et il souligne en bleu le Range de la ligne" .Selection.Sort
Key1:=Range("A1"), Order1:=xlAscending"
est-ce quelqu'un peut m'aider merci.

2 réponses

Avatar
Pottier Jean-Luc
Bien moi je pense qu'il s'agit un problème à la fin de la
ligne.
Essaie la commande suivante :

Pour l'instant tu as :

.Selection.Sort Key1:=Range("A1"), Order1:=xlAscending,
Header:=xlGuess, _
OrderCustom:=1, MatchCase:úlse,
Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal

Fais passer la 2è ligne à la fin de la première.
Ou alors tu rajoute un "_" à la fin de la première ligne
et à la 3è, comme suit : (en fait, fait un copier coller
du code dessous et remplace cette partie dans ta
procédure qui bugge...)

.Selection.Sort Key1:=Range("A1"), Order1:=xlAscending, _
Header:=xlGuess, _
OrderCustom:=1, MatchCase:úlse, _
Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal


-----Message d'origine-----
Voici mon programme.

Public Sub ConvertirEnExcel(fichier As String)
Dim objXL As Object
Screen.MousePointer = 11
Set objXL = CreateObject("Excel.Application")
With objXL
.Visible = True
.workbooks.OpenText FileName:=fichier,


Comma:=True
.Application.DisplayAlerts = False
.Columns("A:A").Select
.Selection.NumberFormat = "mm/dd/yy;@"
.Columns("B:E").Select
.Selection.NumberFormat = "0.00"
.Columns("G:G").Select
.Selection.ClearContents
.Range("A1:F65000").Select
.Selection.Sort Key1:=Range("A1"),


Order1:=xlAscending,
Header:=xlGuess, _
OrderCustom:=1, MatchCase:úlse,


Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
.ActiveWorkbook.SaveAs FileName:=fichier
.workbooks.Close
.Application.Quit
End With

Screen.MousePointer = 1
End Sub
J'obtiens toujours l'erreur de compilation
procedure sub ou fonction non-défini.
Et il souligne en bleu le Range de la


ligne" .Selection.Sort
Key1:=Range("A1"), Order1:=xlAscending"
est-ce quelqu'un peut m'aider merci.


.



Avatar
Zarf
Merci, ça fonctionne
"Pottier Jean-Luc" a écrit dans le
message de news:8d8c01c4786e$e326c100$

Bien moi je pense qu'il s'agit un problème à la fin de la
ligne.
Essaie la commande suivante :

Pour l'instant tu as :

.Selection.Sort Key1:=Range("A1"), Order1:=xlAscending,
Header:=xlGuess, _
OrderCustom:=1, MatchCase:úlse,
Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal

Fais passer la 2è ligne à la fin de la première.
Ou alors tu rajoute un "_" à la fin de la première ligne
et à la 3è, comme suit : (en fait, fait un copier coller
du code dessous et remplace cette partie dans ta
procédure qui bugge...)

.Selection.Sort Key1:=Range("A1"), Order1:=xlAscending, _
Header:=xlGuess, _
OrderCustom:=1, MatchCase:úlse, _
Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal


-----Message d'origine-----
Voici mon programme.

Public Sub ConvertirEnExcel(fichier As String)
Dim objXL As Object
Screen.MousePointer = 11
Set objXL = CreateObject("Excel.Application")
With objXL
.Visible = True
.workbooks.OpenText FileName:=fichier,


Comma:=True
.Application.DisplayAlerts = False
.Columns("A:A").Select
.Selection.NumberFormat = "mm/dd/yy;@"
.Columns("B:E").Select
.Selection.NumberFormat = "0.00"
.Columns("G:G").Select
.Selection.ClearContents
.Range("A1:F65000").Select
.Selection.Sort Key1:=Range("A1"),


Order1:=xlAscending,
Header:=xlGuess, _
OrderCustom:=1, MatchCase:úlse,


Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
.ActiveWorkbook.SaveAs FileName:=fichier
.workbooks.Close
.Application.Quit
End With

Screen.MousePointer = 1
End Sub
J'obtiens toujours l'erreur de compilation
procedure sub ou fonction non-défini.
Et il souligne en bleu le Range de la


ligne" .Selection.Sort
Key1:=Range("A1"), Order1:=xlAscending"
est-ce quelqu'un peut m'aider merci.


.