Twitter iPhone pliant OnePlus 11 PS5 Disney+ Orange Livebox Windows 11

bug vb6 vs excel

2 réponses
Avatar
Marc Paquin
Bonjour,

J'ai un petit trouble avec excel que je controle avec vb6 il me retourne pas
toutes les cellules sélectionnées par l'utilisateur

Voici mes codes pour reproduire l'erreur:
Public objExcel As Excel.Application
Public objWorkbook As Excel.Workbook
Private Sub Command1_Click()
openfichierexcel App.Path & "\Book1.xls", objWorkbook, True, False
End Sub

Private Sub Command2_Click()
Dim forcerange As Range
Set forcerange =
objExcel.Range("B5:B27;F5:F27;H5:H27;J5:J27;L5:L27;N5:N27;P5:P27;R5:R27;T5:T27;V5:V27;X5:X27;Z5:Z27;AB5:AB27;AD5:AD27;AF5:AF27;AH5:AH27;AJ5:AJ27;AL5:AL27;AN5:AN27;AP5:AP27;AR5:AR27;AT5:AT27;AV5:AV27;AX5:AX27;AZ5:AZ27;BB5:BB27;BD5:BD27")
forcerange.Select
Dim getrange As Range
Set getrange = objExcel.Selection
Debug.Print getrange.Address
'me retourne au lieu de la selection originale ->
$B$5:$B$27,$F$5:$F$27,$H$5:$H$27,$J$5:$J$27,$L$5:$L$27,$N$5:$N$27,$P$5:$P$27,$R$5:$R$27,$T$5:$T$27,$V$5:$V$27,$X$5:$X$27,$Z$5:$Z$27,$AB$5:$AB$27,$AD$5:$AD$27,$AF$5:$AF$27,$AH$5:$AH$27,$AJ$5:$AJ$27,$AL$5:$AL$27,$AN$5:$AN$27,$AP$5:$AP$27,$AR$5:$AR$27
End Sub

Sub openfichierexcel(chemin As String, file As Excel.Workbook, visible As
Boolean, alerte As Boolean)
If objExcel Is Nothing Then
Set objExcel = New Excel.Application
End If
objExcel.visible = visible
objExcel.DisplayAlerts = alerte
Set file = objExcel.Workbooks.Open(chemin)
End Sub



Merci

Marc

2 réponses

Avatar
parci
On Fri, 11 Jan 2008 14:41:00 -0500, "Marc Paquin"
wrote:

Bonjour,

J'ai un petit trouble avec excel que je controle avec vb6 il me retourne pas
toutes les cellules sélectionnées par l'utilisateur

Voici mes codes pour reproduire l'erreur:
Public objExcel As Excel.Application
Public objWorkbook As Excel.Workbook
Private Sub Command1_Click()
openfichierexcel App.Path & "Book1.xls", objWorkbook, True, False
End Sub

Private Sub Command2_Click()
Dim forcerange As Range
Set forcerange =
objExcel.Range("B5:B27;F5:F27;H5:H27;J5:J27;L5:L27;N5:N27;P5:P27;R5:R27;T5:T27;V5:V27;X5:X27;Z5:Z27;AB5:AB27;AD5:AD27;AF5:AF27;AH5:AH27;AJ5:AJ27;AL5:AL27;AN5:AN27;AP5:AP27;AR5:AR27;AT5:AT27;AV5:AV27;AX5:AX27;AZ5:AZ27;BB5:BB27;BD5:BD27")
forcerange.Select
Dim getrange As Range
Set getrange = objExcel.Selection
Debug.Print getrange.Address
'me retourne au lieu de la selection originale ->
$B$5:$B$27,$F$5:$F$27,$H$5:$H$27,$J$5:$J$27,$L$5:$L$27,$N$5:$N$27,$P$5:$P$27,$R$5:$R$27,$T$5:$T$27,$V$5:$V$27,$X$5:$X$27,$Z$5:$Z$27,$AB$5:$AB$27,$AD$5:$AD$27,$AF$5:$AF$27,$AH$5:$AH$27,$AJ$5:$AJ$27,$AL$5:$AL$27,$AN$5:$AN$27,$AP$5:$AP$27,$AR$5:$AR$27
End Sub

Sub openfichierexcel(chemin As String, file As Excel.Workbook, visible As
Boolean, alerte As Boolean)
If objExcel Is Nothing Then
Set objExcel = New Excel.Application
End If
objExcel.visible = visible
objExcel.DisplayAlerts = alerte
Set file = objExcel.Workbooks.Open(chemin)
End Sub



Le problème semble venir de la propriété Address qui retourne une
chaine tronquée à 250 caractères maximum. Mais la sélection est
correcte.

Après Debug.Print getrange.Address ajoute ces lignes pour afficher en
debug toutes les adresses des cellules de la plage sélectionnée :

Dim c As Excel.Range
For Each c In getrange
Debug.Print c.Address
Next c
Avatar
Marc Paquin
Merci tu me sauves la vie!


"parci" wrote in message
news:
On Fri, 11 Jan 2008 14:41:00 -0500, "Marc Paquin"
wrote:

Bonjour,

J'ai un petit trouble avec excel que je controle avec vb6 il me retourne
pas
toutes les cellules sélectionnées par l'utilisateur

Voici mes codes pour reproduire l'erreur:
Public objExcel As Excel.Application
Public objWorkbook As Excel.Workbook
Private Sub Command1_Click()
openfichierexcel App.Path & "Book1.xls", objWorkbook, True, False
End Sub

Private Sub Command2_Click()
Dim forcerange As Range
Set forcerange >>objExcel.Range("B5:B27;F5:F27;H5:H27;J5:J27;L5:L27;N5:N27;P5:P27;R5:R27;T5:T27;V5:V27;X5:X27;Z5:Z27;AB5:AB27;AD5:AD27;AF5:AF27;AH5:AH27;AJ5:AJ27;AL5:AL27;AN5:AN27;AP5:AP27;AR5:AR27;AT5:AT27;AV5:AV27;AX5:AX27;AZ5:AZ27;BB5:BB27;BD5:BD27")
forcerange.Select
Dim getrange As Range
Set getrange = objExcel.Selection
Debug.Print getrange.Address
'me retourne au lieu de la selection originale ->
$B$5:$B$27,$F$5:$F$27,$H$5:$H$27,$J$5:$J$27,$L$5:$L$27,$N$5:$N$27,$P$5:$P$27,$R$5:$R$27,$T$5:$T$27,$V$5:$V$27,$X$5:$X$27,$Z$5:$Z$27,$AB$5:$AB$27,$AD$5:$AD$27,$AF$5:$AF$27,$AH$5:$AH$27,$AJ$5:$AJ$27,$AL$5:$AL$27,$AN$5:$AN$27,$AP$5:$AP$27,$AR$5:$AR$27
End Sub

Sub openfichierexcel(chemin As String, file As Excel.Workbook, visible As
Boolean, alerte As Boolean)
If objExcel Is Nothing Then
Set objExcel = New Excel.Application
End If
objExcel.visible = visible
objExcel.DisplayAlerts = alerte
Set file = objExcel.Workbooks.Open(chemin)
End Sub



Le problème semble venir de la propriété Address qui retourne une
chaine tronquée à 250 caractères maximum. Mais la sélection est
correcte.

Après Debug.Print getrange.Address ajoute ces lignes pour afficher en
debug toutes les adresses des cellules de la plage sélectionnée :

Dim c As Excel.Range
For Each c In getrange
Debug.Print c.Address
Next c