'438' propriété ou méthode non gérée par cet objet

Résolu/Fermé
néophite - 23 mars 2015 à 16:43
 néophite - 24 mars 2015 à 10:07
Bonjour,

J'aimerais ajouter un bouton qui m'amène à la feuille que je viens de créer. Mais je n'y arrive pas....
J'ai pourtant activé ma feuille sur laquelle le bouton doit apparaître et testé beaucoup de moyen différent pour activer la cellule où j'aimerais que mon bouton se situ.
Voilà mon code avec en gras la partie délicate (je pense)....

Merci de votre aide!

  
Option Explicit


Private Sub Label1_Click()

End Sub

Private Sub CommandButton1_Click()


' NewGRDF incorporer une nouvelle famille
' Selectionner 2 lignes après la derniere zone de texte dans la colonne B

Dim derlign As Long

derlign = Range("B65536").End(xlUp).Offset(1, 0).Activate

Dim lign As Long

lign = ActiveCell.EntireRow.Select

'Insérer 2 lignes

Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove

'Insérer texte de la textbox1

Dim txt As String

txt = Range("B65536").End(xlUp).Offset(2, 0).Activate
ActiveCell = TextBox1

Dim truc As Byte

truc = ActiveSheet.Index

'Création et nom de la feuille

Dim Ws As Worksheet

Set Ws = Sheets.Add
Ws.Move After:=Worksheets(truc + 1)

'nom deja pris? A FAIRE

Ws.Name = TextBox1

'Insertion du texte dans la feuille

Range("a1") = "Dernière mise à jour:"
Range("b8") = TextBox1
Range("h1") = "Util. :"
Range("c1") = Date

'Inserer un bouton ramenant à la feuille précédente.

'Création du bouton

Dim btnprec As OLEObject

Set btnprec = Ws.OLEObjects.Add("Forms.CommandButton.1")
With btnprec
.Name = "btnprec"
.Left = 50 'position horizontale par rapport au bord gauche de la feuille
.Top = 50 'position verticale par rapport au bord haut de la feuille
.Width = 30 'largeur
.Height = 17 'hauteur
.Object.Caption = "<--"
End With

'Création de la commande

Dim Code As String

Code = "Sub btnprec_Click()" & vbCrLf
Code = Code & "Sheets(""Acceuil"").Select" & vbCrLf
Code = Code & "End Sub"

Dim NextLine As String

With ActiveWorkbook.VBProject.VBComponents(ActiveSheet.CodeName).CodeModule
NextLine = .CountOfLines + 1
.insertlines NextLine, Code
End With




'Insérer un bouton créant une sous famille A FAIRE utiliser une boucle?





'Ajouter un bouton sur la feuille d'accueil pour pouvoir atteindre la NewGRDF

Sheets("acceuil").Activate

'Ajout du bouton

Dim btnGRDF As OLEObject

Range("D23").Activate

Set btnGRDF = Ws.OLEObjects.Add("Forms.CommandButton.1")
With btnGRDF
.Name = "btnGRDF"
.Left = ActiveCell.Left 'position horizontale par rapport au bord gauche de la feuille
.Top = ActiveCell.Top 'position verticale par rapport au bord haut de la feuille
.Width = ActiveCell.Width 'largeur
.Height = ActiveCell.Height 'hauteur
.Object.Caption = "Go"
End With

'Création de la commande

Dim Text As String

btnGRDF.Row.Activate
Text = Cells("activerow", 2).Name

Dim Codex As String

Codex = "Sub btnGRDF_Click()" & vbCrLf
Codex = Codex & "Sheets(""Text"").Select" & vbCrLf
Codex = Codex & "End Sub"

Dim NxtLin As String

With ActiveWorkbook.VBProject.VBComponents(ActiveSheet.CodeName).CodeModule
NxtLin = .CountOfLines + 1
.insertlines NextLine, Codex
End With


NewGRDF.Hide

End Sub


Private Sub TextBox1_Change()

End Sub

Private Sub UserForm_Click()

End Sub




2 réponses

f894009 Messages postés 17185 Date d'inscription dimanche 25 novembre 2007 Statut Membre Dernière intervention 15 avril 2024 1 701
23 mars 2015 à 18:45
0
merci!
0