[VB] Problème de compilation

Fermé
Roland223 - 3 oct. 2009 à 18:01
 Roland223 - 10 oct. 2009 à 16:36
Bonjour,
Je viens soumettre un problème que j'ai avec un fichier XLT.Il s'agit plus précisément d'un logiciel (du nom de CAMELEC) permettant d'effectuer des travaux de calculs et dimensionnement d'éléments de réseaux electrique.
En fouillant un peu le contenu, je me suis rendu compte que les calculs étaient faits à l'aide de 4 macros en Visual Basic.
Le problème, c'est que les calculs ne marchent pas.Lorsque j'appuie sur le bouton principal lançant les calculs je recois un message d'erreur dans une fenêtre Visual Basic Editor libellée : "Erreur de Compilation. Projet ou Bibliothèque Introuvable."

Je signale que mon Solveur est activé, et que je travaille sous la suite Office2007. Le fichier Camelec est un fichier XLT.

Voici le code source des macros VB.
Sub Makro1()
    
    Solverok SetCell:="$e$32", MaxMinVal:=3, ValueOf:="0", ByChange:="$a$38"
    SolverSolve (True)

 
    Solverok SetCell:="$j$32", MaxMinVal:=3, ValueOf:="0", ByChange:="$f$38"
    SolverSolve (True)
    
     
    Solverok SetCell:="$O$32", MaxMinVal:=3, ValueOf:="0", ByChange:="$k$38"
    SolverSolve (True)
    
    MsgBox "Calcul fait. Vérfiez convergence (Solveur à zéro)"
    

End Sub


Sub Makro3()
'
' Makro3 Makro
' Makro indspillet 24-05-2002 af Preben Jørgensen
'

'
    ActiveSheet.Shapes("Button 15").Select
    Application.CommandBars("Stop Recording").Visible = False
    Selection.Characters.Text = "Calculez" & Chr(10) & ""
    With Selection.Characters(Start:=1, Length:=8).Font
        .Name = "Arial"
        .FontStyle = "Fed kursiv"
        .Size = 16
        .Strikethrough = False
        .Superscript = False
        .Subscript = False
        .OutlineFont = False
        .Shadow = False
        .Underline = xlUnderlineStyleNone
        .ColorIndex = 3
    End With
    With Selection.Characters(Start:=9, Length:=1).Font
        .Name = "Arial"
        .FontStyle = "Fed kursiv"
        .Size = 12
        .Strikethrough = False
        .Superscript = False
        .Subscript = False
        .OutlineFont = False
        .Shadow = False
        .Underline = xlUnderlineStyleNone
        .ColorIndex = 3
    End With
    Range("O22").Select
    Application.Run "Camelec.XLT!Makro1"
    Application.Run "Camelec.XLT!Makro1"
    ActiveWorkbook.Save
    ActiveWorkbook.RunAutoMacros Which:=xlAutoClose
    Application.Run "Camelec.XLT!Makro1"
    Range("L19").Select
    ActiveWorkbook.SaveAs Filename:= _
        "C:\Documents and Settings\Preben\Skrivebord\Camelec.XLT", FileFormat _
        :=xlTemplate, Password:="", WriteResPassword:="", ReadOnlyRecommended:= _
        False, CreateBackup:=False
End Sub

Sub Makro4()
    Solverok SetCell:="$e$198", MaxMinVal:=3, ValueOf:="0", ByChange:="$a$204"
    SolverSolve (True)
    
    Solverok SetCell:="$e$212", MaxMinVal:=3, ValueOf:="0", ByChange:="$a$218"
    SolverSolve (True)
    
    Solverok SetCell:="$e$226", MaxMinVal:=3, ValueOf:="0", ByChange:="$a$232"
    SolverSolve (True)
    
    Solverok SetCell:="$e$240", MaxMinVal:=3, ValueOf:="0", ByChange:="$a$246"
    SolverSolve (True)
    
    Solverok SetCell:="$e$254", MaxMinVal:=3, ValueOf:="0", ByChange:="$a$260"
    SolverSolve (True)
    
    Solverok SetCell:="$e$268", MaxMinVal:=3, ValueOf:="0", ByChange:="$a$274"
    SolverSolve (True)
    
    Solverok SetCell:="$e$282", MaxMinVal:=3, ValueOf:="0", ByChange:="$a$288"
    SolverSolve (True)
    
    Solverok SetCell:="$j$198", MaxMinVal:=3, ValueOf:="0", ByChange:="$f$204"
    SolverSolve (True)
    
    Solverok SetCell:="$j$212", MaxMinVal:=3, ValueOf:="0", ByChange:="$f$218"
    SolverSolve (True)
    
    Solverok SetCell:="$j$226", MaxMinVal:=3, ValueOf:="0", ByChange:="$f$232"
    SolverSolve (True)
    
    Solverok SetCell:="$j$240", MaxMinVal:=3, ValueOf:="0", ByChange:="$f$246"
    SolverSolve (True)
    
    Solverok SetCell:="$j$254", MaxMinVal:=3, ValueOf:="0", ByChange:="$f$260"
    SolverSolve (True)
    
    Solverok SetCell:="$j$268", MaxMinVal:=3, ValueOf:="0", ByChange:="$f$274"
    SolverSolve (True)
    
    Solverok SetCell:="$j$282", MaxMinVal:=3, ValueOf:="0", ByChange:="$f$288"
    SolverSolve (True)
    
    Solverok SetCell:="$o$198", MaxMinVal:=3, ValueOf:="0", ByChange:="$k$204"
    SolverSolve (True)
    
    Solverok SetCell:="$o$212", MaxMinVal:=3, ValueOf:="0", ByChange:="$k$218"
    SolverSolve (True)
    
    Solverok SetCell:="$o$226", MaxMinVal:=3, ValueOf:="0", ByChange:="$k$232"
    SolverSolve (True)
    
    Solverok SetCell:="$o$240", MaxMinVal:=3, ValueOf:="0", ByChange:="$k$246"
    SolverSolve (True)
    
    Solverok SetCell:="$o$254", MaxMinVal:=3, ValueOf:="0", ByChange:="$k$260"
    SolverSolve (True)
    
    Solverok SetCell:="$o$268", MaxMinVal:=3, ValueOf:="0", ByChange:="$k$274"
    SolverSolve (True)
    
    Solverok SetCell:="$o$282", MaxMinVal:=3, ValueOf:="0", ByChange:="$k$288"
    SolverSolve (True)
    
    Solverok SetCell:="$t$198", MaxMinVal:=3, ValueOf:="0", ByChange:="$p$204"
    SolverSolve (True)
    
    Solverok SetCell:="$t$212", MaxMinVal:=3, ValueOf:="0", ByChange:="$p$218"
    SolverSolve (True)
    
    Solverok SetCell:="$t$226", MaxMinVal:=3, ValueOf:="0", ByChange:="$p$232"
    SolverSolve (True)
    
    Solverok SetCell:="$t$240", MaxMinVal:=3, ValueOf:="0", ByChange:="$p$246"
    SolverSolve (True)
    
    Solverok SetCell:="$t$254", MaxMinVal:=3, ValueOf:="0", ByChange:="$p$260"
    SolverSolve (True)
    
    Solverok SetCell:="$t$268", MaxMinVal:=3, ValueOf:="0", ByChange:="$p$274"
    SolverSolve (True)
    
    Solverok SetCell:="$t$282", MaxMinVal:=3, ValueOf:="0", ByChange:="$p$288"
    SolverSolve (True)
    
    Solverok SetCell:="$y$198", MaxMinVal:=3, ValueOf:="0", ByChange:="$u$204"
    SolverSolve (True)
    
    Solverok SetCell:="$y$212", MaxMinVal:=3, ValueOf:="0", ByChange:="$u$218"
    SolverSolve (True)
    
    Solverok SetCell:="$y$226", MaxMinVal:=3, ValueOf:="0", ByChange:="$u$232"
    SolverSolve (True)
    
    Solverok SetCell:="$y$240", MaxMinVal:=3, ValueOf:="0", ByChange:="$u$246"
    SolverSolve (True)
    
    Solverok SetCell:="$y$254", MaxMinVal:=3, ValueOf:="0", ByChange:="$u$260"
    SolverSolve (True)
    
    Solverok SetCell:="$y$268", MaxMinVal:=3, ValueOf:="0", ByChange:="$u$274"
    SolverSolve (True)
    
    Solverok SetCell:="$y$282", MaxMinVal:=3, ValueOf:="0", ByChange:="$u$288"
    SolverSolve (True)
    
    Solverok SetCell:="$ad$198", MaxMinVal:=3, ValueOf:="0", ByChange:="$z$204"
    SolverSolve (True)
    
    Solverok SetCell:="$ad$212", MaxMinVal:=3, ValueOf:="0", ByChange:="$z$218"
    SolverSolve (True)
    
    Solverok SetCell:="$ad$226", MaxMinVal:=3, ValueOf:="0", ByChange:="$z$232"
    SolverSolve (True)
    
    Solverok SetCell:="$ad$240", MaxMinVal:=3, ValueOf:="0", ByChange:="$z$246"
    SolverSolve (True)
    
    Solverok SetCell:="$ad$254", MaxMinVal:=3, ValueOf:="0", ByChange:="$z$260"
    SolverSolve (True)
    
    Solverok SetCell:="$ad$268", MaxMinVal:=3, ValueOf:="0", ByChange:="$z$274"
    SolverSolve (True)
    
    Solverok SetCell:="$ad$282", MaxMinVal:=3, ValueOf:="0", ByChange:="$z$288"
    SolverSolve (True)
    
    
    MsgBox "Calcul fait. Vérfiez convergence (Solveur à zéro)"
    

End Sub


Sub Makro5()
'
' Makro5 Makro
' Makro indspillet 24-05-2002 af Preben Jørgensen
'

'
    ActiveSheet.Shapes("Button 15").Select
    Application.CommandBars("Stop Recording").Visible = False
    Selection.Characters.Text = "Calculez" & Chr(10) & ""
    With Selection.Characters(Start:=1, Length:=8).Font
        .Name = "Arial"
        .FontStyle = "Fed kursiv"
        .Size = 16
        .Strikethrough = False
        .Superscript = False
        .Subscript = False
        .OutlineFont = False
        .Shadow = False
        .Underline = xlUnderlineStyleNone
        .ColorIndex = 3
    End With
    With Selection.Characters(Start:=9, Length:=1).Font
        .Name = "Arial"
        .FontStyle = "Fed kursiv"
        .Size = 12
        .Strikethrough = False
        .Superscript = False
        .Subscript = False
        .OutlineFont = False
        .Shadow = False
        .Underline = xlUnderlineStyleNone
        .ColorIndex = 3
    End With
    Range("O22").Select
    Application.Run "Camelec.XLT!Makro4"
    Application.Run "Camelec.XLT!Makro4"
    ActiveWorkbook.Save
    ActiveWorkbook.RunAutoMacros Which:=xlAutoClose
    Application.Run "Camelec.XLT!Makro4"
    Range("L19").Select
    ActiveWorkbook.SaveAs Filename:= _
        "C:\Documents and Settings\Preben\Skrivebord\Camelec.XLT", FileFormat _
        :=xlTemplate, Password:="", WriteResPassword:="", ReadOnlyRecommended:= _
        False, CreateBackup:=False
End Sub




Le problème semble venir de la primière ligne de chaque sous macro, plus précisément la commande "Solverok".

Je fournis également le fichier XLT, au cas où cela serait nécessaire.
Telecharger Camelec.xlt: http://www.files.to/get/783387/ixcptuubl5>CamELEC.XLT

Grand merci d'avance.
A voir également:

2 réponses

Roland223 Messages postés 36 Date d'inscription vendredi 7 novembre 2008 Statut Membre Dernière intervention 9 mars 2012 2
4 oct. 2009 à 19:05
Up...
0
La solution que j'ai trouvé a été d'installer Excel 2003 (en parrallèle avec Office 2007) dans un dossier répertoire différent de celui d'oFfice par défaut.J'ai juste installé Excel 2003, activé le Complément Solver, les macros, et cocher avec succès la réf Solver (Outils - > Références ) . Et là ça marche impeccablement
Affaire résolue donc!
0