Xynder59
Messages postés48Date d'inscriptionlundi 13 octobre 2003StatutMembreDernière intervention13 septembre 2007
-
11 août 2006 à 07:33
Xynder59
Messages postés48Date d'inscriptionlundi 13 octobre 2003StatutMembreDernière intervention13 septembre 2007
-
15 août 2006 à 07:23
Bonjour les p'tits loups voilà mon problème,
je fais appel à un tableau excel dans mon programme en VB6, voilà mon bout de code pour appeler le tableau :
Puis ensuite j'utilise d'autres fonctions pour mette des données dans ce tableau, pour cela aucun problème.
Mon problème est le suivant, le tableau se lance 1 fois puis les fois suivante on ne le voit pas, juste la barre windows du haut...????
Pour bien faire je dois fermer le programme et recommencer
Ne faut-il pas fermer l'instruction excel mais comment ?!
mortalino
Messages postés6786Date d'inscriptionvendredi 16 décembre 2005StatutMembreDernière intervention21 décembre 201118 11 août 2006 à 23:04
Salut,
ifaza : le on error resume next est la facilité mais les syntaxes à problèmes ne sont pas exécutés.
Xynder : ton code n'est pas suffisant, il y a une multitudes de choses qui font que ton code peut 'planter'.
Met nous les Set xlApp = ..., ce genre de chose.
@++
Mortalino
Le mystérieux chevalier, "Provençal, le Gaulois"
Xynder59
Messages postés48Date d'inscriptionlundi 13 octobre 2003StatutMembreDernière intervention13 septembre 2007 12 août 2006 à 07:31
Très bien voilà le code, attention il est peut être un peu primaire mais je l'ai fait en 10min:
Dim xlApp As New Excel.Application
Private Sub Command1_Click()
'je commence par fermer les feuilles ouvertes occasionnelles
xlApp.Quit
Set xlApp = Nothing
xlApp.Visible = True
xlApp.Workbooks.Add
xlApp.DisplayAlerts = False
On Error Resume Next
Call init
End Sub
Private Sub init()
Dim an As Integer
Dim mois As String
Dim N°mois As Integer
an = Format(Me.jour, "yyyy")
mois = Format(Me.jour, "mmmm")
N°mois = Format(Me.jour, "mm")
Call création_feuille(N°mois, mois, an)
ActiveWindow.TabRatio = 0.939
End Sub
'création de la feuille
Public Sub création_feuille(num_mois, mois, an)
Dim cool As String
cool = "01/" & num_mois & "/" & an
Sheets.Add ' << le message d'erreur intervient ici
ActiveSheet.Name = mois
Range("A1").Select
ActiveCell.FormulaR1C1 = mois & " " & an
Selection.Font.Bold = True
Call ajout_jour
ActiveWindow.TabRatio = 0.939
Range("A2") = Format(cool, "dddd")
Call ajout
End Sub
Public Sub ajout_jour()
x = "C2:AG2"
If Range("A1") = "Février" Then
x = "C2:AE2"
ElseIf Range("A1") "Avril" Or Range("A1") "Juin" Or Range("A1") = "Septembre" Or Range("A1") = "Novembre" Then
x = "C2:AF2"
End If
End If
Range("C2").Select
ActiveCell.FormulaR1C1 = "1"
Range("D2").Select
ActiveCell.FormulaR1C1 = "2"
Range("C2:D2").Select
Selection.AutoFill Destination:=Range(x), Type:=xlFillDefault
Range("C2:AG2").Select
Selection.ColumnWidth = 2
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
End With
With ActiveWindow
.DisplayGridlines = False
.DisplayHeadings = False
End With
End Sub
Public Sub ajout()
x = "C1:AG1"
If Range("A1") = "Février" Then
x = "C1:AE1"
ElseIf Range("A1") "Avril" Or Range("A1") "Juin" Or Range("A1") = "Septembre" Or Range("A1") = "Novembre" Then
x = "C1:AF1"
End If
End If
If Range("A2") = "dimanche" Then
Range("C1").Select
ActiveCell.FormulaR1C1 = "D"
Range("D1").Select
ActiveCell.FormulaR1C1 = "L"
Range("E1").Select
ActiveCell.FormulaR1C1 = "M"
Range("F1").Select
ActiveCell.FormulaR1C1 = "M"
Range("G1").Select
ActiveCell.FormulaR1C1 = "J"
Range("H1").Select
ActiveCell.FormulaR1C1 = "V"
Range("I1").Select
ActiveCell.FormulaR1C1 = "S"
Range("C1:I1").Select
Selection.AutoFill Destination:=Range(x), Type:=xlFillDefault
End If
If Range("A2") = "lundi" Then
Range("C1").Select
ActiveCell.FormulaR1C1 = "L"
Range("D1").Select
ActiveCell.FormulaR1C1 = "M"
Range("E1").Select
ActiveCell.FormulaR1C1 = "M"
Range("F1").Select
ActiveCell.FormulaR1C1 = "J"
Range("G1").Select
ActiveCell.FormulaR1C1 = "V"
Range("H1").Select
ActiveCell.FormulaR1C1 = "S"
Range("I1").Select
ActiveCell.FormulaR1C1 = "D"
Range("C1:I1").Select
Selection.AutoFill Destination:=Range(x), Type:=xlFillDefault
End If
If Range("A2") = "mardi" Then
Range("C1").Select
ActiveCell.FormulaR1C1 = "M"
Range("D1").Select
ActiveCell.FormulaR1C1 = "M"
Range("E1").Select
ActiveCell.FormulaR1C1 = "J"
Range("F1").Select
ActiveCell.FormulaR1C1 = "V"
Range("G1").Select
ActiveCell.FormulaR1C1 = "S"
Range("H1").Select
ActiveCell.FormulaR1C1 = "D"
Range("I1").Select
ActiveCell.FormulaR1C1 = "L"
Range("C1:I1").Select
Selection.AutoFill Destination:=Range(x), Type:=xlFillDefault
End If
If Range("A2") = "mercredi" Then
Range("C1").Select
ActiveCell.FormulaR1C1 = "M"
Range("D1").Select
ActiveCell.FormulaR1C1 = "J"
Range("E1").Select
ActiveCell.FormulaR1C1 = "V"
Range("F1").Select
ActiveCell.FormulaR1C1 = "S"
Range("G1").Select
ActiveCell.FormulaR1C1 = "D"
Range("H1").Select
ActiveCell.FormulaR1C1 = "L"
Range("I1").Select
ActiveCell.FormulaR1C1 = "M"
Range("C1:I1").Select
Selection.AutoFill Destination:=Range(x), Type:=xlFillDefault
End If
If Range("A2") = "jeudi" Then
Range("C1").Select
ActiveCell.FormulaR1C1 = "J"
Range("D1").Select
ActiveCell.FormulaR1C1 = "V"
Range("E1").Select
ActiveCell.FormulaR1C1 = "S"
Range("F1").Select
ActiveCell.FormulaR1C1 = "D"
Range("G1").Select
ActiveCell.FormulaR1C1 = "L"
Range("H1").Select
ActiveCell.FormulaR1C1 = "M"
Range("I1").Select
ActiveCell.FormulaR1C1 = "M"
Range("C1:I1").Select
Selection.AutoFill Destination:=Range(x), Type:=xlFillDefault
End If
If Range("A2") = "vendredi" Then
Range("C1").Select
ActiveCell.FormulaR1C1 = "V"
Range("D1").Select
ActiveCell.FormulaR1C1 = "S"
Range("E1").Select
ActiveCell.FormulaR1C1 = "D"
Range("F1").Select
ActiveCell.FormulaR1C1 = "L"
Range("G1").Select
ActiveCell.FormulaR1C1 = "M"
Range("H1").Select
ActiveCell.FormulaR1C1 = "M"
Range("I1").Select
ActiveCell.FormulaR1C1 = "J"
Range("C1:I1").Select
Selection.AutoFill Destination:=Range(x), Type:=xlFillDefault
End If
If Range("A2") = "samedi" Then
Range("C1").Select
ActiveCell.FormulaR1C1 = "S"
Range("D1").Select
ActiveCell.FormulaR1C1 = "D"
Range("E1").Select
ActiveCell.FormulaR1C1 = "L"
Range("F1").Select
ActiveCell.FormulaR1C1 = "M"
Range("G1").Select
ActiveCell.FormulaR1C1 = "M"
Range("H1").Select
ActiveCell.FormulaR1C1 = "J"
Range("I1").Select
ActiveCell.FormulaR1C1 = "V"
Range("C1:I1").Select
Selection.AutoFill Destination:=Range(x), Type:=xlFillDefault
End If
Range("C1:AG1").Select
Selection.ColumnWidth = 2
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
End With
With ActiveWindow
.DisplayGridlines = False
.DisplayHeadings = False
End With
Range("A2") = ""
End Sub
'Fin création de feuille
Voilà il s'agit en fait du haut d'un calendrier automatique, c'est cette partie qui mere une fois sur deux....
Xynder59
Messages postés48Date d'inscriptionlundi 13 octobre 2003StatutMembreDernière intervention13 septembre 2007 15 août 2006 à 07:23
xlApp.Worksheets.Add m'affiche la page mais pas les élèments que je lui envoi,
Sheets.Add fonctionne très bien mais une fois seulement, si je ferme le programme et que je le redemarre, cela fonctionne !!!!!