cs_piou62
Messages postés40Date d'inscriptionvendredi 4 avril 2008StatutMembreDernière intervention12 septembre 2012
-
29 mai 2008 à 16:31
PCPT
Messages postés13272Date d'inscriptionlundi 13 décembre 2004StatutMembreDernière intervention 3 février 2018
-
5 juin 2008 à 00:09
Bonjour,
Je vous explique, je sais pas ce que j'ai fait mais quand je lance mon appli en VB6, les boutons, les frames et le menu de ma forme n'"existe" plus.
Ma forme s'appelle Principal et qaund j'écrit Principal. dans la forme normalement j'ai accès à tous les boutons et autres controls, donc je suis sensé pouvoir écrire Principal.bouton41.Visible = True mais là plus possible il ne connait plus le bouton.
pile_poil
Messages postés682Date d'inscriptionvendredi 6 avril 2007StatutMembreDernière intervention 4 août 20126 29 mai 2008 à 19:07
Private Sub Boutoneleve1_Click()
Dim Wrd As Object
Dim wbExcel As Object
Dim wsExcel As Object
Set Wrd = CreateObject("Excel.Application")
Set wbExcel = Wrd.Workbooks.Open(CommonDialog1.FileName)
Set wsExcel = wbExcel.Worksheets("Liste des sections")
ceci est juste pour te montrer comment déja faire moins lourd
je n'ai pas corrigé un bouton complet mais seulement les trois premieres conditions te laissant le soin de faire le reste
on pourrait le faire aussi comme suit
Private Sub Boutoneleve1_Click()
Dim Wrd As Object
Dim wbExcel As Object
Dim wsExcel As Object
Set Wrd = CreateObject("Excel.Application")
Set wbExcel = Wrd.Workbooks.Open(CommonDialog1.FileName)
Set wsExcel = wbExcel.Worksheets("Liste des sections")
Wrd.DisplayAlerts = False
Select Case wsExcel.Cells(4, 27)
Case "NEWELEVE"
wsExcel.Cells(2, 27) = wsExcel.Cells(1, 1).Value
NouvEnregEleve
Case "MODIFSECTION"
wsExcel.Cells(2, 27) = wsExcel.Cells(1, 1).Value
ModificationSection
Case "MODIFELEVE"
wsExcel.Cells(2, 27) = wsExcel.Cells(1, 1).Value
ModificationFicheEleve
End Select
Wrd.Save
Wrd.Workbooks.Close
End Sub
[reglement.aspx ]si c'est la solution, penser : REPONSE ACCEPTEE
PCPT
Messages postés13272Date d'inscriptionlundi 13 décembre 2004StatutMembreDernière intervention 3 février 201847 29 mai 2008 à 19:38
euh..... et tu arrives à te relire dans tout çà ?
déjà si tu as cette tonne * 72, on peut supposer que tu as trop de lignes pour une feuille....
il faut essayer de factoriser, gagner quelques lignes, surtout pour la lisibilité. remet le nez dans ton code dans un an, j'te mets au défit de le débugger...
ensuite en VB6 tu as les groupes de contrôles, ce qui permettra de ne pas avoir 72* le même code.
à toi de voir, je n'ai pas regardé les similitudes entre boutin1 et bouton2
voici, pour bouton1, unemanière un peu plus claire de procéder :
Private Sub Boutoneleve1_Click()
Dim Wrd As Object
Dim wbExcel As Object
Dim wsExcel As Object
Dim nomfeuille As String
Set Wrd = CreateObject("Excel.Application")
Set wbExcel = Wrd.Workbooks.Open(CommonDialog1.FileName)
Set wsExcel = wbExcel.Worksheets("Liste des
sections")
nomfeuille = wsExcel.Cells(2, 27).Value
Select Case wsExcel.Cells(4, 27)
Case "NEWELEVE"
wsExcel.Cells(2, 27) = wsExcel.Cells(1, 1).Value
SaveWRD Wrd
NouvEnregEleve
Case "MODIFSECTION:"
wsExcel.Cells(2, 27) = wsExcel.Cells(1, 1).Value
SaveWRD Wrd
ModificationSection
Case "MODIFELEVE":
wsExcel.Cells(2, 27) = wsExcel.Cells(1, 1).Value
SaveWRD Wrd
ModificationFicheEleve
Case "SUPSECTION":
wsExcel.Cells(2, 27) = wsExcel.Cells(1, 1).Value
SaveWRD Wrd
SupprimerSection
Case "DESISTELEVE":
wsExcel.Cells(2, 27) = wsExcel.Cells(1, 1).Value
SaveWRD Wrd
DesistementEleve
PCPT
Messages postés13272Date d'inscriptionlundi 13 décembre 2004StatutMembreDernière intervention 3 février 201847 30 mai 2008 à 12:31
1) constante public, sauf comme le dit pile_poil si la valeur change, dans quel cas variable public qu'il faut, un moment, initialiser....
tout çà se fait dans un module à rajouter
plus d'infos :
Q : [doc/faq.aspx#vb_varpublic Code : Comment conserver le contenu d'une
variable entre différents formulaires]
2) tu ne peux pas, pas la place d'afficher....
<hr size="2" width="100%" />Prenez un instant pour répondre à [infomsg_SONDAGE-POP3-POUR-CS_769706.aspx ce sondage] svp
PCPT
Messages postés13272Date d'inscriptionlundi 13 décembre 2004StatutMembreDernière intervention 3 février 201847 4 juin 2008 à 14:06
Private Sub SaveWRD(ByRef oWrd As Object)
oWrd est de type OBJECT
Dim Wrd, wbExcel, wsExcel As Object tu n'as pas typé Wrd et wbExcel, ils sont donc de type VARIANT
or comme c'est un argument BYREF qui est attendu, les types doivent impérativement être les mêmes....
Dim Wrd as Object, wbExcel as Object, wsExcel As Object
<hr size="2" width="100%" />Prenez un instant pour répondre à [infomsg_SONDAGE-POP3-POUR-CS_769706.aspx ce sondage] svp
PCPT
Messages postés13272Date d'inscriptionlundi 13 décembre 2004StatutMembreDernière intervention 3 février 201847 29 mai 2008 à 17:23
salut,
tu parles uniquement de l'intellisense donc?...
plusieurs possibilités...
un usercontrol actif en mode édition, genre avec un timer...
un usercontrol mal codé, en mode édition, ouvert en même temps que ta fenêtre de code
un objet (usercontrol ou class) avec une erreur de code, genre :
private property get machin as string
end property
private property let machin(truc as pas_string)
end property
ou simplement 2 fonctions public portant le même nom dans le même module
et il doit bien encore y avoir une centaine de raisons possibles...
<hr size="2" width="100%" />Prenez un instant pour répondre à [infomsg_SONDAGE-POP3-POUR-CS_769706.aspx ce sondage] svp
cs_piou62
Messages postés40Date d'inscriptionvendredi 4 avril 2008StatutMembreDernière intervention12 septembre 2012 29 mai 2008 à 18:01
bon alors je vais la refaire et copier les codes dans la nouvelle forme.
mais de ce fait je me permet de vous poser une autre question voila, comme je suis débutant, j'ai mis 75 boutons sur la forme.
Je vous met le code des boutons 1 et 2 sachant que le reste est identique:
Je pense qu'il doit être possible de modifier pour créer les boutons avec add et faire un seul code style boutonelevei_click
je sais c'est lourd, mais je débute ...
Private Sub Boutoneleve1_Click()
Dim Wrd As Object
Dim wbExcel As Object
Dim wsExcel As Object
Dim NomMacro, nomfeuille As String
Set Wrd = CreateObject("Excel.Application")
Set wbExcel = Wrd.Workbooks.Open(CommonDialog1.FileName)
Set wsExcel = wbExcel.Worksheets("Liste des sections")
nomfeuille = wsExcel.Cells(2, 27).Value
If wsExcel.Cells(4, 27) "NEWELEVE" Then NomMacro "NEWELEVE"If NomMacro "NEWELEVE" Then wsExcel.Cells(2, 27) wsExcel.Cells(1, 1).ValueIf NomMacro "NEWELEVE" Then Wrd.DisplayAlerts False
If NomMacro = "NEWELEVE" Then Wrd.Save
If NomMacro = "NEWELEVE" Then Wrd.Workbooks.Close
If NomMacro = "NEWELEVE" Then NouvEnregEleve
If NomMacro = "NEWELEVE" Then Exit Sub
If wsExcel.Cells(4, 27) "MODIFSECTION" Then NomMacro "MODIFSECTION"If NomMacro "MODIFSECTION" Then wsExcel.Cells(2, 27) wsExcel.Cells(1, 1).ValueIf NomMacro "MODIFSECTION" Then Wrd.DisplayAlerts False
If NomMacro = "MODIFSECTION" Then Wrd.Save
If NomMacro = "MODIFSECTION" Then Wrd.Workbooks.Close
If NomMacro = "MODIFSECTION" Then ModificationSection
If NomMacro = "MODIFSECTION" Then Exit Sub
If wsExcel.Cells(4, 27) "MODIFELEVE" Then NomMacro "MODIFELEVE"If NomMacro "MODIFELEVE" Then wsExcel.Cells(2, 27) wsExcel.Cells(1, 1).ValueIf NomMacro "MODIFELEVE" Then Wrd.DisplayAlerts False
If NomMacro = "MODIFELEVE" Then Wrd.Save
If NomMacro = "MODIFELEVE" Then Wrd.Workbooks.Close
If NomMacro = "MODIFELEVE" Then ModificationFicheEleve
If NomMacro = "MODIFELEVE" Then Exit Sub
If wsExcel.Cells(4, 27) "SUPSECTION" Then NomMacro "SUPSECTION"If NomMacro "SUPSECTION" Then wsExcel.Cells(2, 27) wsExcel.Cells(1, 1).ValueIf NomMacro "SUPSECTION" Then Wrd.DisplayAlerts False
If NomMacro = "SUPSECTION" Then Wrd.Save
If NomMacro = "SUPSECTION" Then Wrd.Workbooks.Close
If NomMacro = "SUPSECTION" Then SupprimerSection
If NomMacro = "SUPSECTION" Then Exit Sub
If wsExcel.Cells(4, 27) "DESISTELEVE" Then NomMacro "DESISTELEVE"If NomMacro "DESISTELEVE" Then wsExcel.Cells(2, 27) wsExcel.Cells(1, 1).ValueIf NomMacro "DESISTELEVE" Then Wrd.DisplayAlerts False
If NomMacro = "DESISTELEVE" Then Wrd.Save
If NomMacro = "DESISTELEVE" Then Wrd.Workbooks.Close
If NomMacro = "DESISTELEVE" Then DesistementEleve
If NomMacro = "DESISTELEVE" Then Exit Sub
If wsExcel.Cells(4, 27) "MODIFPROF" Then NomMacro "MODIFPROF"If NomMacro "MODIFPROF" Then wsExcel.Cells(2, 28) wbExcel.Worksheets("Professeurs").Cells(2, 2).ValueIf NomMacro "MODIFPROF" Then wsExcel.Cells(2, 29) wbExcel.Worksheets("Professeurs").Cells(2, 3).ValueIf NomMacro "MODIFPROF" Then wsExcel.Cells(2, 30) wbExcel.Worksheets("Professeurs").Cells(2, 4).ValueIf NomMacro "MODIFPROF" Then Wrd.DisplayAlerts False
If NomMacro = "MODIFPROF" Then Wrd.Save
If NomMacro = "MODIFPROF" Then Wrd.Workbooks.Close
If NomMacro = "MODIFPROF" Then ModificationProfesseur
If NomMacro = "MODIFPROF" Then Exit Sub
If wsExcel.Cells(4, 27) "DESISTPROF" Then NomMacro "DESISTPROF"If NomMacro "DESISTPROF" Then wsExcel.Cells(2, 28) wbExcel.Worksheets("Professeurs").Cells(2, 2).ValueIf NomMacro "DESISTPROF" Then wsExcel.Cells(2, 29) wbExcel.Worksheets("Professeurs").Cells(2, 3).ValueIf NomMacro "DESISTPROF" Then wsExcel.Cells(2, 30) wbExcel.Worksheets("Professeurs").Cells(2, 4).ValueIf NomMacro "DESISTPROF" Then Wrd.DisplayAlerts False
If NomMacro = "DESISTPROF" Then Wrd.Save
If NomMacro = "DESISTPROF" Then Wrd.Workbooks.Close
If NomMacro = "DESISTPROF" Then DesistementProfesseur
If NomMacro = "DESISTPROF" Then Exit Sub
If wsExcel.Cells(4, 27) "MODIFNOTES" Then NomMacro "MODIFNOTES"If NomMacro "MODIFNOTES" Then wsExcel.Cells(2, 27) wsExcel.Cells(1, 1).ValueIf NomMacro "MODIFNOTES" Then Wrd.DisplayAlerts False
If NomMacro = "MODIFNOTES" Then Wrd.Save
If NomMacro = "MODIFNOTES" Then Wrd.Workbooks.Close
If NomMacro = "MODIFNOTES" Then ModificationNotes
If NomMacro = "MODIFNOTES" Then Exit Sub
If wsExcel.Cells(4, 27) "MODIFPLANINGSECTION" Then NomMacro "MODIFPLANINGSECTION"If NomMacro "MODIFPLANINGSECTION" Then wsExcel.Cells(2, 27) wsExcel.Cells(1, 1).ValueIf NomMacro "MODIFPLANINGSECTION" Then Wrd.DisplayAlerts False
If NomMacro = "MODIFPLANINGSECTION" Then Wrd.Save
If NomMacro = "MODIFPLANINGSECTION" Then Wrd.Workbooks.Close
If NomMacro = "MODIFPLANINGSECTION" Then ModificationPlaningSection
If NomMacro = "MODIFPLANINGSECTION" Then Exit Sub
If wsExcel.Cells(4, 27) "MODIFPLANINGSALLE" Then NomMacro "MODIFPLANINGSALLE"If NomMacro "MODIFPLANINGSALLE" Then wsExcel.Cells(2, 27) wsExcel.Cells(1, 1).ValueIf NomMacro "MODIFPLANINGSALLE" Then Wrd.DisplayAlerts False
If NomMacro = "MODIFPLANINGSALLE" Then Wrd.Save
If NomMacro = "MODIFPLANINGSALLE" Then Wrd.Workbooks.Close
If NomMacro = "MODIFPLANINGSALLE" Then ModificationPlaningSalle
If NomMacro = "MODIFPLANINGSALLE" Then Exit Sub
If wsExcel.Cells(4, 27) "MODFIELEVE" Then NomMacro "MODFIELEVE"If NomMacro "MODFIELEVE" Then wsExcel.Cells(2, 28) wbExcel.Worksheets(nomfeuille).Cells(2, 2).ValueIf NomMacro "MODFIELEVE" Then wsExcel.Cells(2, 29) wbExcel.Worksheets(nomfeuille).Cells(2, 3).ValueIf NomMacro "MODFIELEVE" Then wsExcel.Cells(2, 30) wbExcel.Worksheets(nomfeuille).Cells(2, 4).ValueIf NomMacro "MODFIELEVE" Then Wrd.DisplayAlerts False
If NomMacro = "MODFIELEVE" Then Wrd.Save
If NomMacro = "MODFIELEVE" Then Wrd.Workbooks.Close
If NomMacro = "MODFIELEVE" Then ModFiEleve
If NomMacro = "MODFIELEVE" Then Exit Sub
If wsExcel.Cells(4, 27) "DESELEVE" Then NomMacro "DESELEVE"If NomMacro "DESELEVE" Then wsExcel.Cells(2, 28) wbExcel.Worksheets(nomfeuille).Cells(2, 2).ValueIf NomMacro "DESELEVE" Then wsExcel.Cells(2, 29) wbExcel.Worksheets(nomfeuille).Cells(2, 3).ValueIf NomMacro "DESELEVE" Then wsExcel.Cells(2, 30) wbExcel.Worksheets(nomfeuille).Cells(2, 4).ValueIf NomMacro "DESELEVE" Then Wrd.DisplayAlerts False
If NomMacro = "DESELEVE" Then Wrd.Save
If NomMacro = "DESELEVE" Then Wrd.Workbooks.Close
If NomMacro = "DESELEVE" Then Deseleve
If NomMacro = "DESELEVE" Then Exit Sub
If wsExcel.Cells(4, 27) "LISTESECTION" Then NomMacro "LISTESECTION"If NomMacro "LISTESECTION" Then wsExcel.Cells(15, 49) wsExcel.Cells(15, 49) + 1If NomMacro "LISTESECTION" Then wsExcel.Cells(15, (49 + wsExcel.Cells(15, 49))) wsExcel.Cells(1, 1).ValueIf NomMacro "LISTESECTION" Then Wrd.DisplayAlerts False
If NomMacro = "LISTESECTION" Then Wrd.Save
If NomMacro = "LISTESECTION" Then Wrd.Workbooks.Close
If NomMacro = "LISTESECTION" Then ListeEleveSection
If NomMacro = "LISTESECTION" Then Exit Sub
If wsExcel.Cells(4, 27) "LISTEIMP" Then NomMacro "LISTEIMP"If NomMacro "LISTEIMP" Then Wrd.DisplayAlerts False
If NomMacro = "LISTEIMP" Then Wrd.Save
If NomMacro = "LISTEIMP" Then Wrd.Workbooks.Close
If NomMacro = "LISTEIMP" Then ImpressionPDF
If NomMacro = "LISTEIMP" Then Exit Sub
If wsExcel.Cells(4, 27) "CREERFICHIEREXCEL" Then NomMacro "CREERFICHIEREXCEL"If NomMacro "CREERFICHIEREXCEL" Then wsExcel.Cells(2, 28) wbExcel.Worksheets("Professeurs").Cells(2, 2).ValueIf NomMacro "CREERFICHIEREXCEL" Then wsExcel.Cells(2, 29) wbExcel.Worksheets("Professeurs").Cells(2, 3).ValueIf NomMacro "CREERFICHIEREXCEL" Then Wrd.DisplayAlerts False
If NomMacro = "CREERFICHIEREXCEL" Then Wrd.Save
If NomMacro = "CREERFICHIEREXCEL" Then Wrd.Workbooks.Close
If NomMacro = "CREERFICHIEREXCEL" Then CREERFICHIEREXCEL
If NomMacro = "CREERFICHIEREXCEL" Then Exit Sub
If wsExcel.Cells(4, 27) "BULLETINSECTION" Then NomMacro "BULLETINSECTION"If NomMacro "BULLETINSECTION" Then wsExcel.Cells(2, 27) wsExcel.Cells(1, 1).ValueIf NomMacro "BULLETINSECTION" Then Wrd.DisplayAlerts False
If NomMacro = "BULLETINSECTION" Then Wrd.Save
If NomMacro = "BULLETINSECTION" Then Wrd.Workbooks.Close
If NomMacro = "BULLETINSECTION" Then BulletinSection
If NomMacro = "BULLETINSECTION" Then Exit Sub
If wsExcel.Cells(4, 27) "BULLELEVESECT" Then NomMacro "BULLELEVESECT"If NomMacro "BULLELEVESECT" Then wsExcel.Cells(2, 27) wsExcel.Cells(1, 1).ValueIf NomMacro "BULLELEVESECT" Then Wrd.DisplayAlerts False
If NomMacro = "BULLELEVESECT" Then Wrd.Save
If NomMacro = "BULLELEVESECT" Then Wrd.Workbooks.Close
If NomMacro = "BULLELEVESECT" Then bullelevesect
If NomMacro = "BULLELEVESECT" Then Exit Sub
If wsExcel.Cells(4, 27) "BULLELEVE" Then NomMacro "BULLELEVE"If NomMacro "BULLELEVE" Then wsExcel.Cells(2, 28) wbExcel.Worksheets(nomfeuille).Cells(2, 2).ValueIf NomMacro "BULLELEVE" Then wsExcel.Cells(2, 29) wbExcel.Worksheets(nomfeuille).Cells(2, 3).ValueIf NomMacro "BULLELEVE" Then wsExcel.Cells(2, 30) wbExcel.Worksheets(nomfeuille).Cells(2, 4).ValueIf NomMacro "BULLELEVE" Then Wrd.DisplayAlerts False
If NomMacro = "BULLELEVE" Then Wrd.Save
If NomMacro = "BULLELEVE" Then Wrd.Workbooks.Close
If NomMacro = "BULLELEVE" Then Bulleleve
If NomMacro = "BULLELEVE" Then Exit Sub
End Sub
Private Sub Boutoneleve2_Click()
Dim Wrd As Object
Dim wbExcel As Object
Dim wsExcel As Object
Dim NomMacro, nomfeuille As String
Set Wrd = CreateObject("Excel.Application")
Set wbExcel = Wrd.Workbooks.Open(CommonDialog1.FileName)
Set wsExcel = wbExcel.Worksheets("Liste des sections")
nomfeuille = wsExcel.Cells(2, 27).Value
If wsExcel.Cells(4, 27) "NEWELEVE" Then NomMacro "NEWELEVE"If NomMacro "NEWELEVE" Then wsExcel.Cells(2, 27) wsExcel.Cells(2, 1).ValueIf NomMacro "NEWELEVE" Then Wrd.DisplayAlerts False
If NomMacro = "NEWELEVE" Then Wrd.Save
If NomMacro = "NEWELEVE" Then Wrd.Workbooks.Close
If NomMacro = "NEWELEVE" Then NouvEnregEleve
If NomMacro = "NEWELEVE" Then Exit Sub
If wsExcel.Cells(4, 27) "MODIFSECTION" Then NomMacro "MODIFSECTION"If NomMacro "MODIFSECTION" Then wsExcel.Cells(2, 27) wsExcel.Cells(2, 1).ValueIf NomMacro "MODIFSECTION" Then Wrd.DisplayAlerts False
If NomMacro = "MODIFSECTION" Then Wrd.Save
If NomMacro = "MODIFSECTION" Then Wrd.Workbooks.Close
If NomMacro = "MODIFSECTION" Then ModificationSection
If NomMacro = "MODIFSECTION" Then Exit Sub
If wsExcel.Cells(4, 27) "MODIFELEVE" Then NomMacro "MODIFELEVE"If NomMacro "MODIFELEVE" Then wsExcel.Cells(2, 27) wsExcel.Cells(2, 1).ValueIf NomMacro "MODIFELEVE" Then Wrd.DisplayAlerts False
If NomMacro = "MODIFELEVE" Then Wrd.Save
If NomMacro = "MODIFELEVE" Then Wrd.Workbooks.Close
If NomMacro = "MODIFELEVE" Then ModificationFicheEleve
If NomMacro = "MODIFELEVE" Then Exit Sub
If wsExcel.Cells(4, 27) "SUPSECTION" Then NomMacro "SUPSECTION"If NomMacro "SUPSECTION" Then wsExcel.Cells(2, 27) wsExcel.Cells(2, 1).ValueIf NomMacro "SUPSECTION" Then Wrd.DisplayAlerts False
If NomMacro = "SUPSECTION" Then Wrd.Save
If NomMacro = "SUPSECTION" Then Wrd.Workbooks.Close
If NomMacro = "SUPSECTION" Then SupprimerSection
If NomMacro = "SUPSECTION" Then Exit Sub
If wsExcel.Cells(4, 27) "DESISTELEVE" Then NomMacro "DESISTELEVE"If NomMacro "DESISTELEVE" Then wsExcel.Cells(2, 27) wsExcel.Cells(2, 1).ValueIf NomMacro "DESISTELEVE" Then Wrd.DisplayAlerts False
If NomMacro = "DESISTELEVE" Then Wrd.Save
If NomMacro = "DESISTELEVE" Then Wrd.Workbooks.Close
If NomMacro = "DESISTELEVE" Then DesistementEleve
If NomMacro = "DESISTELEVE" Then Exit Sub
If wsExcel.Cells(4, 27) "MODIFPROF" Then NomMacro "MODIFPROF"If NomMacro "MODIFPROF" Then wsExcel.Cells(2, 28) wbExcel.Worksheets("Professeurs").Cells(3, 2).ValueIf NomMacro "MODIFPROF" Then wsExcel.Cells(2, 29) wbExcel.Worksheets("Professeurs").Cells(3, 3).ValueIf NomMacro "MODIFPROF" Then wsExcel.Cells(2, 30) wbExcel.Worksheets("Professeurs").Cells(3, 4).ValueIf NomMacro "MODIFPROF" Then Wrd.DisplayAlerts False
If NomMacro = "MODIFPROF" Then Wrd.Save
If NomMacro = "MODIFPROF" Then Wrd.Workbooks.Close
If NomMacro = "MODIFPROF" Then ModificationProfesseur
If NomMacro = "MODIFPROF" Then Exit Sub
If wsExcel.Cells(4, 27) "DESISTPROF" Then NomMacro "DESISTPROF"If NomMacro "DESISTPROF" Then wsExcel.Cells(2, 28) wbExcel.Worksheets("Professeurs").Cells(3, 2).ValueIf NomMacro "DESISTPROF" Then wsExcel.Cells(2, 29) wbExcel.Worksheets("Professeurs").Cells(3, 3).ValueIf NomMacro "DESISTPROF" Then wsExcel.Cells(2, 30) wbExcel.Worksheets("Professeurs").Cells(3, 4).ValueIf NomMacro "DESISTPROF" Then Wrd.DisplayAlerts False
If NomMacro = "DESISTPROF" Then Wrd.Save
If NomMacro = "DESISTPROF" Then Wrd.Workbooks.Close
If NomMacro = "DESISTPROF" Then DesistementProfesseur
If NomMacro = "DESISTPROF" Then Exit Sub
If wsExcel.Cells(4, 27) "MODIFNOTES" Then NomMacro "MODIFNOTES"If NomMacro "MODIFNOTES" Then wsExcel.Cells(2, 27) wsExcel.Cells(2, 1).ValueIf NomMacro "MODIFNOTES" Then Wrd.DisplayAlerts False
If NomMacro = "MODIFNOTES" Then Wrd.Save
If NomMacro = "MODIFNOTES" Then Wrd.Workbooks.Close
If NomMacro = "MODIFNOTES" Then ModificationNotes
If NomMacro = "MODIFNOTES" Then Exit Sub
If wsExcel.Cells(4, 27) "MODIFPLANINGSECTION" Then NomMacro "MODIFPLANINGSECTION"If NomMacro "MODIFPLANINGSECTION" Then wsExcel.Cells(2, 27) wsExcel.Cells(2, 1).ValueIf NomMacro "MODIFPLANINGSECTION" Then Wrd.DisplayAlerts False
If NomMacro = "MODIFPLANINGSECTION" Then Wrd.Save
If NomMacro = "MODIFPLANINGSECTION" Then Wrd.Workbooks.Close
If NomMacro = "MODIFPLANINGSECTION" Then ModificationPlaningSection
If NomMacro = "MODIFPLANINGSECTION" Then Exit Sub
If wsExcel.Cells(4, 27) "MODIFPLANINGSALLE" Then NomMacro "MODIFPLANINGSALLE"If NomMacro "MODIFPLANINGSALLE" Then wsExcel.Cells(2, 27) wsExcel.Cells(2, 1).ValueIf NomMacro "MODIFPLANINGSALLE" Then Wrd.DisplayAlerts False
If NomMacro = "MODIFPLANINGSALLE" Then Wrd.Save
If NomMacro = "MODIFPLANINGSALLE" Then Wrd.Workbooks.Close
If NomMacro = "MODIFPLANINGSALLE" Then ModificationPlaningSalle
If NomMacro = "MODIFPLANINGSALLE" Then Exit Sub
If wsExcel.Cells(4, 27) "MODFIELEVE" Then NomMacro "MODFIELEVE"If NomMacro "MODFIELEVE" Then wsExcel.Cells(2, 28) wbExcel.Worksheets(nomfeuille).Cells(3, 2).ValueIf NomMacro "MODFIELEVE" Then wsExcel.Cells(2, 29) wbExcel.Worksheets(nomfeuille).Cells(3, 3).ValueIf NomMacro "MODFIELEVE" Then wsExcel.Cells(2, 30) wbExcel.Worksheets(nomfeuille).Cells(3, 4).ValueIf NomMacro "MODFIELEVE" Then Wrd.DisplayAlerts False
If NomMacro = "MODFIELEVE" Then Wrd.Save
If NomMacro = "MODFIELEVE" Then Wrd.Workbooks.Close
If NomMacro = "MODFIELEVE" Then ModFiEleve
If NomMacro = "MODFIELEVE" Then Exit Sub
If wsExcel.Cells(4, 27) "DESELEVE" Then NomMacro "DESELEVE"If NomMacro "DESELEVE" Then wsExcel.Cells(2, 28) wbExcel.Worksheets(nomfeuille).Cells(3, 2).ValueIf NomMacro "DESELEVE" Then wsExcel.Cells(2, 29) wbExcel.Worksheets(nomfeuille).Cells(3, 3).ValueIf NomMacro "DESELEVE" Then wsExcel.Cells(2, 30) wbExcel.Worksheets(nomfeuille).Cells(3, 4).ValueIf NomMacro "DESELEVE" Then Wrd.DisplayAlerts False
If NomMacro = "DESELEVE" Then Wrd.Save
If NomMacro = "DESELEVE" Then Wrd.Workbooks.Close
If NomMacro = "DESELEVE" Then Deseleve
If NomMacro = "DESELEVE" Then Exit Sub
If wsExcel.Cells(4, 27) "LISTESECTION" Then NomMacro "LISTESECTION"If NomMacro "LISTESECTION" Then wsExcel.Cells(15, 49) wsExcel.Cells(15, 49) + 1If NomMacro "LISTESECTION" Then wsExcel.Cells(15, (49 + wsExcel.Cells(15, 49))) wsExcel.Cells(2, 1).ValueIf NomMacro "LISTESECTION" Then Wrd.DisplayAlerts False
If NomMacro = "LISTESECTION" Then Wrd.Save
If NomMacro = "LISTESECTION" Then Wrd.Workbooks.Close
If NomMacro = "LISTESECTION" Then ListeEleveSection
If NomMacro = "LISTESECTION" Then Exit Sub
If wsExcel.Cells(4, 27) "LISTEIMP" Then NomMacro "LISTEIMP"If NomMacro "LISTEIMP" Then Wrd.DisplayAlerts False
If NomMacro = "LISTEIMP" Then Wrd.Save
If NomMacro = "LISTEIMP" Then Wrd.Workbooks.Close
If NomMacro = "LISTEIMP" Then ImpressionPapier
If NomMacro = "LISTEIMP" Then Exit Sub
If wsExcel.Cells(4, 27) "CREERFICHIEREXCEL" Then NomMacro "CREERFICHIEREXCEL"If NomMacro "CREERFICHIEREXCEL" Then wsExcel.Cells(2, 28) wbExcel.Worksheets("Professeurs").Cells(3, 2).ValueIf NomMacro "CREERFICHIEREXCEL" Then wsExcel.Cells(2, 29) wbExcel.Worksheets("Professeurs").Cells(3, 3).ValueIf NomMacro "CREERFICHIEREXCEL" Then Wrd.DisplayAlerts False
If NomMacro = "CREERFICHIEREXCEL" Then Wrd.Save
If NomMacro = "CREERFICHIEREXCEL" Then Wrd.Workbooks.Close
If NomMacro = "CREERFICHIEREXCEL" Then CREERFICHIEREXCEL
If NomMacro = "CREERFICHIEREXCEL" Then Exit Sub
cs_piou62
Messages postés40Date d'inscriptionvendredi 4 avril 2008StatutMembreDernière intervention12 septembre 2012 30 mai 2008 à 12:03
Merci beaucoup, c'est mieux, et en créant un groupe de controle, c'est plus propre comme programmation.
Je vais me permettre de vous poser 2 autres questions (comme je vois que les gens de ce site sont compétents)
1. Est-il possible d'écrire 2 lignes dans le caption d'une forme ?
2. Comment fait-on pour définir une constante style nom d'une feuille utilisable dans toutes les macro sans devoir à chaque fois faire référence à une cellule.
Moi ce que je fais (et la aussi c'est lourd), c'est que j'écrit dans une case par ex le nom d'une feuille et quand à chaque macro, je vais voir le nom indiqué dans la feuille.
pile_poil
Messages postés682Date d'inscriptionvendredi 6 avril 2007StatutMembreDernière intervention 4 août 20126 30 mai 2008 à 12:11
pour ta uestion 2 utiliser une constante n'est pas la solution puisque c'est un codage hard donc si ta sheet change de nom ça plante
utilise plutot une variable publique que tu déclares dans un module
tu fais ensuite une petite sub pour trouver le nom de la sheet à mettre dans cette variable et ensuite dans le reste de ton code il suffit d'utiliser cette variable
pour la premiere
Label = "toto" & Chr(13) & "truc"
[reglement.aspx ]si c'est la solution, penser : REPONSE ACCEPTEE
cs_piou62
Messages postés40Date d'inscriptionvendredi 4 avril 2008StatutMembreDernière intervention12 septembre 2012 4 juin 2008 à 13:48
Re, j'ai encore un souci, vous m'avez donné comme code pour fermer excel :
Private Sub SaveWRD(ByRef oWrd As Object)
With oWrd
.DisplayAlerts = False
.Save
.Workbooks.Close
End With
End Sub
Et j'ai voulu l'utiliser dans d'autres macro ex:
Private Sub OuvrirFichier_Click()
Reset
Dim Wrd, wbExcel, wsExcel As Object
Dim i, ctr As Integer
Dim nomfeuille, nometab As String
Principal.CommonDialog1.ShowOpen
Set Wrd = CreateObject("Excel.Application")
Set wbExcel = Wrd.Workbooks.Open(CommonDialog1.FileName)
Set wsExcel = wbExcel.Worksheets(1)
wbExcel.Worksheets("Liste des sections").Cells(10, 27) = Date
Wrd.Visible = False
nometab = wbExcel.Worksheets("Liste des sections").Cells(1, 20)
Principal.Caption = Date & " : Centre de " & nometab & " : " & CommonDialog1.FileName & " Ouvrir un fichier"
cs_piou62
Messages postés40Date d'inscriptionvendredi 4 avril 2008StatutMembreDernière intervention12 septembre 2012 4 juin 2008 à 15:37
Re,
autant pour moi j'avais mal lu,
je pensais que l'on pouvais mettre Dim X, V, S, E, As Object
et est-ce que c'est pareil pour les integer, les controls, les string ...
parce que j'ai à chauqe fois mis i, u, t, y, as integer ou label, textbox as control ...