Passage excel 2003 à 2007 : TREEVIEW ne fonctionne plus
vampirius666
Messages postés2Date d'inscriptionlundi 19 juillet 2010StatutMembreDernière intervention 2 août 2010
-
2 août 2010 à 11:12
scromania
Messages postés452Date d'inscriptiondimanche 20 août 2006StatutMembreDernière intervention11 janvier 2013
-
2 août 2010 à 11:45
Bonjours à tous !
J'apprécie énormément les forums sur internet grâce auxquels j'ai réussi pleins de truc en VB. Notamment un super tableur avec un treeview, des Userforms ... etc ..
Cependant je rencontre un gros problème lors de l'utilisation de mon fichier excel ( créé sur excel 2003) avec excel 2007. Certaines références "ne passent pas bien" d'une version à l'autre, notamment celles liées à mon Treeview. Mon super treeview qui fonctionne super bien sur excel 2003 ne marche pas du tout sur excel 2007. Problème : l'entreprise pour laquelle je fais mon stage ne travaille que sur 2007 ( j'ai mon ordi perso avec 2003)
voici l'erreur : "erreur de compilation : Projet ou bibliothèque non trouvée"
voici le code, et l'endroit où l'erreur apparaît :
Sub UserForm_Initialize()
Me.OptionButton1 = True ' by défault the selection is in mode DUTY
Me.OptionButton4 = True ' by défault, We don't add a phantome
'Purpose: Load userform with desired defaults
Dim Last_row As Integer
Dim i As Integer
Dim Phantom As Integer
'Set control defaults
With Me
.CommandButton1.Caption = "EXIT"
.Label1 = vbNullString
.TreeView1.LineStyle = tvwRootLines ERROR : erreur de compilation : Projet ou bibliothèque non trouvée.
.Top = Application.Height - (Me.Height + 30) ' place the UF in the middle of the screen
.Left = Application.Width - (Me.Width + 30) ' place the UF on the right of the screen
End With
' here it's to remove added alines if the add wasn't properly finished.
Last_row = Worksheets("Treeview").Range("A1").End(xlDown).Row
For i = 1 To Last_row
If Sheets("Treeview").Range("A" & i).Value = "---" Then
If Sheets("Treeview").Range("B" & i).Value = "---" Then
If Sheets("Treeview").Range("C" & i).Value = "" Then ' then it's a bug and we have to delete this line
Sheets("Treeview").Rows(i & ":" & i).Delete
i = i - 1
End If
End If
End If
Next i
' lin deleted
'Populate the Treeview
Call TreeView_Populate
End Sub
Private Sub TreeView_Populate()
'Purpose: Populate the treeview control
Dim Range_Node As Range
Dim Node_ As Range
Dim Last_row As Integer
Dim Max_Last_column As Single
Dim Father As Range
Dim row_parent As Integer
Dim row_child As Integer
Dim Delta_row As Integer
Dim i As Integer
Dim k As Integer
Worksheets("Treeview").Activate
Last_row = Worksheets("Treeview").Range("A1").End(xlDown).Row
Dim Last_column() As Integer ' for each line of the sheet, i'm looking for the number of filed columns : Last_column (1) = << number of column of the line 1>> _
<< Last_column (2) = << number of column of the line 2>>
For i = 1 To Last_row
ReDim Preserve Last_column(i) ' IMPORTANT !
Last_column(i) = Sheets("Treeview").Cells(i, 1).End(xlToRight).Column
Next i
' look after the maximum. The farthest filed column
Max_Last_column = Last_column(1) 'hypothesis
For i = 2 To Last_row
If Last_column(i) > Max_Last_column Then
Max_Last_column = Last_column(i)
End If
Next i
'max fund
' ADD of the categories nodes
Sheets("Treeview").Range("A1").Select ' It's works column after column
Set Range_Node = Range(Selection, Selection.End(xlDown)) ' first column selection
For Each Node_ In Range_Node ' for each CAtegories contained by this range
If Node_ <> "---" Then
If Node_ <> "" Then
Me.TreeView1.Nodes.ADD , , Node_.Address, Node_.Text
Me.TreeView1.Nodes.Item(Node_.Address).Bold = True
End If
End If
Next Node_
' Categories OK
' ADD the others nodes, column after columns
For i = 3 To Max_Last_column ' Categories Nodes are already dones ( columns 1 et 2 )
Worksheets("Treeview").Cells(1, 1).Select
Set Range_Node = Range(Cells(1, i), Cells(Last_row, i))
'rebulding of the treeview from the excel sheet.
If (i Mod 2) <> 0 Then ' If the column is odd ( 3, 5, 7 etc..)
For Each Node_ In Range_Node
If Node_ <> "---" Then
If Node_ <> "" Then
If Node_ <> ">>>" Then
k = 0
Do While Node_.Offset(-k, 0).Value <> ">>>" ' We go up to find the father
k = k + 1
row_parent = Node_.Offset(-k, 0).Row
Loop
row_child = Node_.Row ' line of the child
Delta_row = row_child - row_parent
Node_.Offset(-Delta_row, -2).Select ' father selection
Me.TreeView1.Nodes.ADD Selection.Address, tvwChild, Node_.Address, Node_.Text ' the child is added to te TV with a "twchild" relation with his father ERROR : erreur de compilation : Projet ou bibliothèque non trouvée.
If Worksheets("Treeview").Range(Node_.Address).Offset(0, 1).Value = "phantom" Then
Me.TreeView1.Nodes.Item(Node_.Address).ForeColor = &H80000011 ' Phantom are always Grey. I can assume that. I already saw one.
End If
End If
End If
End If
Next Node_
End If
Next i
End Sub
Pouvez-vous m'aider à résoudre ce problème ?
J ai déjà trouvé des indices pour nous aider :
Déjà, première mauvaise nouvelle sur un site de Microsoft, un forum, il y a un tas de gens d'entreprises qui se plaignent que les clients, passés sous excel 2007 ( les boulets ...) ne peuvent plus utiliser les Treeview contenus dans les logiciels vendus.
Et microsoft reconnaît le problème lié au "kill bit" ( j'ai pas compris ce que c'est), mais ne propose pas de solution simple et efficace pour corriger le problème.
la page en question ( en anglais ) >>> http://social.msdn.microsoft.com/Forums/en/exceldev/thread/e4914d43-d5fa-4095-a66e-92c9465484dc
ça commence par " Hi,I am really hoping someone can help me......."
Donc en passant sur 2007, il semble que j'ai des références qui soient devenues pourries et qui ne soient plus reconnues.
Comment je peux faire pour régler le problème ? Est-ce que d'autres personnes ont ce problème et comment vous faites ? est-ce que c'est possible de "reconstruire" manuellement mon Userform "TREEVIEW" à partir d'un nouveau fichier EXCEL 2007 ? en copiant mon code SUB par SUB ? Est-ce que ça permettrait de faire appel aux références valides d'Excel 2007 ?
Si Quelqu'un avait des infos à me fournir, ça pourrais ... me sauver la vie ! Car si mon logiciel ne peut pas fonctionner sur les machines de l'entreprise Bah .... mon stage aura servit à RIEN ! ! 0/ 20 et trop la honte ...
merci d'avance pour votre aide,,
Thomas
A voir également:
Passage excel 2003 à 2007 : TREEVIEW ne fonctionne plus
scromania
Messages postés452Date d'inscriptiondimanche 20 août 2006StatutMembreDernière intervention11 janvier 20139 2 août 2010 à 11:45
effectivement du passage 2003 à 2007 sa ne fonctionne plus
va dans les proprietes puis dans référence,tu supprime tes reference 2003 et tu ajoute Microsoft excel 12.0 Object library et automatiquement il va ajouter Microsoft office 12.0 Object library et Microsoft visual basic for application extensibility 5.3
voilou @ ++