Center un texte dans Excel avec VB.Net

Résolu
testuaure Messages postés 3 Date d'inscription lundi 3 mars 2008 Statut Membre Dernière intervention 4 mars 2008 - 4 mars 2008 à 11:22
jrivet Messages postés 7392 Date d'inscription mercredi 23 avril 2003 Statut Membre Dernière intervention 6 avril 2012 - 4 mars 2008 à 14:57
Bonjour,

Je suis en train de faire un petit programme en VB qui m'envoie les TextBox dans une cellule mais je n'arrive pas à centrer le text.
Voici quelques lignes:
With oSheet.Range("A1", "A13").Font.Bold True.HorizontalAlignment "center"

End
WithoXL.Quit()
oSheet NothingoBook

NothingoXL =

Nothing

Catch ex As ExceptionErrStr "Erreur " & vbCrLf & _

ex.ToString

GoTo fout

End
TryMsgBox("Enregistrement des modifications effectué")

Exit
SubSi vous pouviez éclairer ma lanterne ca serait cool
merci d'avance

Aurel

5 réponses

jrivet Messages postés 7392 Date d'inscription mercredi 23 avril 2003 Statut Membre Dernière intervention 6 avril 2012 60
4 mars 2008 à 11:28
Salut,
Essaie peu etre

   With oSheet.Range("A1", "A13")
       .Font.Bold = True
       .HorizontalAlignment = xlCenter
   
   End With

   Call oXL.Quit
   Set oSheet = Nothing
   Set oBook = Nothing
   Set oXL = Nothing
   Catch ex As Exception       ErrStr "Erreur " & vbCrLf & _
       ex.ToString
   GoTo fout

   End Try

   MsgBox ("Enregistrement des modifications effectué")
Exit Sub , ----
[code.aspx?ID=41455 By Renfield]

@+: Ju£i?n
Pensez: Réponse acceptée
3
jrivet Messages postés 7392 Date d'inscription mercredi 23 avril 2003 Statut Membre Dernière intervention 6 avril 2012 60
4 mars 2008 à 12:32
Salut,
Dans ce cas remplace XlCenter par sa valeur

   With oSheet.Range("A1", "A13")
       .Font.Bold = True        .HorizontalAlignment &HFFFFEFF4 '&HFFFFEFF4 -4108 = XlCenter

   
   End With

   Call oXL.Quit
   Set oSheet = Nothing
   Set oBook = Nothing
   Set oXL = Nothing
   Catch ex As Exception        ErrStr <gras>"Erreur " </gras>& vbCrLf & _
       ex.ToString
   GoTo fout

   End Try

   MsgBox ("Enregistrement des modifications effectué")
Exit Sub

@+: Ju£i?n
Pensez: Réponse acceptée
3
testuaure Messages postés 3 Date d'inscription lundi 3 mars 2008 Statut Membre Dernière intervention 4 mars 2008
4 mars 2008 à 11:56
Merci mais j'avais deja essayé avec oXL.Center mais ca ne marche pas.
car dans mon programme c'est oXL = CreateObject("Excel.Application")

Aurel
0
testuaure Messages postés 3 Date d'inscription lundi 3 mars 2008 Statut Membre Dernière intervention 4 mars 2008
4 mars 2008 à 14:18
Merci pour ta rapidité et ton talent.
Tu as resolu mon probleme.
A charge de revenche.

Aurel
0

Vous n’avez pas trouvé la réponse que vous recherchez ?

Posez votre question
jrivet Messages postés 7392 Date d'inscription mercredi 23 avril 2003 Statut Membre Dernière intervention 6 avril 2012 60
4 mars 2008 à 14:57
Re,
Mais y a pas de quoi.
Une fois que l'ont sais que xlcenter est une constante, ca va mieux

@+: Ju£i?n
Pensez: Réponse acceptée
0
Rejoignez-nous