Sub CreateCommandBar()
'Ajoute la barre de commandes "VB France"
On Error Resume Next
CommandBars("VB France").Delete
On Error GoTo 0
With CommandBars.Add("VB France")
With .Controls.Add(msoControlButton)
.Caption = " Source de données (ODBC) "
.OnAction = "DisplayODBCManager"
End With
With .Controls.Add(msoControlPopup)
.Caption = " Macros "
.BeginGroup = True
With .Controls.Add(msoControlButton)
.Caption = "Convertir en nombre (format standard)"
.OnAction = "ConvertStrToDbl"
End With
With .Controls.Add(msoControlButton)
.Caption = "Appliquer le format monétaire"
.BeginGroup = True
.OnAction = "ApplyCurrencyFormat"
End With
With .Controls.Add(msoControlButton)
.Caption = "Appliquer le format pourcentage"
.OnAction = "ApplyPercentageFormat"
End With
With .Controls.Add(msoControlButton)
.Caption = "Corriger les dates enregistrées au format anglais"
.BeginGroup = True
.OnAction = "ModifyDateFormat"
End With
End With
.Visible = True
End With
End Sub
FENETRES
Messages postés196Date d'inscriptionjeudi 15 juillet 2004StatutMembreDernière intervention14 avril 2009 2 mars 2007 à 12:00
'Annule et remplace le commentaire précédent
Sub CreateCommandBar()
'Ajoute la barre d'outils "VB France"
On Error Resume Next
CommandBars("VB France").Delete
On Error GoTo 0
With CommandBars.Add(Name:="VB France")
With .Controls.Add(Type:=msoControlPopup)
.Caption = "Macros" + Space(25)
With .Controls.Add(msoControlButton)
.OnAction = "ConvertStrToDbl"
.Caption = "Convertir en nombre (format standard)"
End With
With .Controls.Add(msoControlButton)
.OnAction = "ApplyCurrencyFormat"
.Caption = "Appliquer le format monétaire"
.BeginGroup = True
End With
With .Controls.Add(msoControlButton)
.OnAction = "ApplyPercentageFormat"
.Caption = "Appliquer le format pourcentage"
End With
With .Controls.Add(msoControlButton)
.OnAction = "ModifyDateFormat"
.Caption = "Corriger les dates enregistrées au format anglais"
.BeginGroup = True
End With
End With
.Visible = True
End With
End Sub
FENETRES
Messages postés196Date d'inscriptionjeudi 15 juillet 2004StatutMembreDernière intervention14 avril 2009 2 mars 2007 à 11:43
'Ajouter la procédure ci-dessous pour créer une nouvelle barre d'outils
Sub CreateCommandBar()
On Error Resume Next
CommandBars("BTD Consulting").Delete
On Error GoTo 0
With CommandBars.Add(Name:="VB France")
With .Controls.Add(Type:=msoControlPopup)
.Caption = "Macros" + Space(25)
.TooltipText = ""
With .Controls.Add(msoControlButton)
.OnAction = "ConvertStrToDbl"
.Caption = "Convertir en nombre (format standard)"
End With
With .Controls.Add(msoControlButton)
.FaceId = 0
.OnAction = "ApplyCurrencyFormat"
.Caption = "Appliquer le format monétaire"
.BeginGroup = True
End With
With .Controls.Add(msoControlButton)
.FaceId = 0
.OnAction = "ApplyPercentageFormat"
.Caption = "Appliquer le format pourcentage"
End With
With .Controls.Add(msoControlButton)
.FaceId = 0
.OnAction = "ModifyDateFormat"
.Caption = "Corriger les dates enregistrées au format anglais"
.BeginGroup = True
End With
End With
.Visible = True
End With
End Sub
FENETRES
Messages postés196Date d'inscriptionjeudi 15 juillet 2004StatutMembreDernière intervention14 avril 2009 6 févr. 2007 à 16:40
Proverbe du jour :
« Cent fois sur le métier, tu remettras ton ouvrage.»
FENETRES
Messages postés196Date d'inscriptionjeudi 15 juillet 2004StatutMembreDernière intervention14 avril 2009 30 janv. 2007 à 09:54
'Version finale tenant compte de la conversion d'un format nombre en pourcentage. Mille excuses pour ma distraction.
'Annule et remplace les exemples précédents en commentaire car il ne faut pas oublier de diviser ou multiplier par 100.
Sub setPercentageFormat()
'Affecte le format pourcentage à la plage sélectionnée
'Variables de traitement
Dim myNumber As Double
Dim myRange As Range
'Gestionnaire d'erreur
On Error GoTo Except
For Each myRange In Selection
With myRange
If Right(.Value, 1) = "%" Then
If IsNumeric(Left(.Value, Len(.Value) - 1)) Then
myNumber = Left(.Value, Len(.Value) - 1) / 100
.NumberFormat = "#,##0.00 %"
.Value = myNumber
End If
ElseIf IsNumeric(.Value) Then
myNumber = .Value * 100
.NumberFormat = "#,##0.00 %"
.Value = myNumber
End If
End With
Next
Exit Sub
Except:
'Boîte de dialogue : message d'erreur
Call MsgBox(vbCr & "Erreur n° " & Err.Number & vbCr & vbCr & _
Err.Description & Space(6), vbCritical + vbOKOnly, " Macro de MAJ du format pourcentage")
End Sub
FENETRES
Messages postés196Date d'inscriptionjeudi 15 juillet 2004StatutMembreDernière intervention14 avril 2009 29 janv. 2007 à 17:28
'Annule et remplace les exemples précédents en commentaire car il ne faut pas oublier de diviser par 100.
Sub setPercentageFormat()
'Affecte le format pourcentage à la plage sélectionnée
'Variables de traitement
Dim myNumber As Double
Dim myRange As Range
'Gestionnaire d'erreur
On Error GoTo Except
For Each myRange In Selection
With myRange
If Right(.Value, 1) = "%" Then
If IsNumeric(Left(.Value, Len(.Value) - 1)) Then
myNumber = Left(.Value, Len(.Value) - 1) / 100
.NumberFormat = "#,##0.00 %"
.Value = myNumber
End If
ElseIf IsNumeric(.Value) Then
myNumber = .Value / 100
.NumberFormat = "#,##0.00 %"
.Value = myNumber
End If
End With
Next
Exit Sub
Except:
'Boîte de dialogue : message d'erreur
Call MsgBox(vbCr & "Erreur n° " & Err.Number & vbCr & vbCr & _
Err.Description & Space(6), vbCritical + vbOKOnly, " Macro de MAJ du format pourcentage")
End Sub
FENETRES
Messages postés196Date d'inscriptionjeudi 15 juillet 2004StatutMembreDernière intervention14 avril 2009 29 janv. 2007 à 17:17
'Plus exactement :
Sub setPercentageFormat()
'Affecte le format pourcentage à la plage sélectionnée
'Variables de traitement
Dim myNumber As Double
Dim myRange As Range
'Gestionnaire d'erreur
On Error GoTo Except
For Each myRange In Selection
With myRange
If Right(.Value, 1) = "%" Then
If IsNumeric(Left(.Value, Len(.Value) - 1)) Then
myNumber = Left(.Value, Len(.Value) - 1)
.NumberFormat = "#,##0.00 %"
.Value = myNumber
End If
ElseIf IsNumeric(.Value) Then
myNumber = .Value
.NumberFormat = "#,##0.00 %"
.Value = myNumber
End If
End With
Next
Exit Sub
Except:
'Boîte de dialogue : message d'erreur
Call MsgBox(vbCr & "Erreur n° " & Err.Number & vbCr & vbCr & _
Err.Description & Space(6), vbCritical + vbOKOnly, " Macro de MAJ du format pourcentage")
End Sub
FENETRES
Messages postés196Date d'inscriptionjeudi 15 juillet 2004StatutMembreDernière intervention14 avril 2009 29 janv. 2007 à 17:12
'Idem pour le format pourcentage
Sub setPercentageFormat()
'Affecte le format pourcentage à la plage sélectionnée
'Variables de traitement
Dim myNumber As Double
Dim myRange As Range
'Gestionnaire d'erreur
On Error GoTo Except
For Each myRange In Selection
With myRange
If Right(.Value, 1) = "%" Then
If IsNumeric(Left(.Value, Len(.Value) - 1)) Then
myNumber = Left(.Value, Len(.Value) - 1)
.NumberFormat = "#,##0.00 %"
.Value = myNumber
End If
End If
End With
Next
Exit Sub
Except:
'Boîte de dialogue : message d'erreur
Call MsgBox(vbCr & "Erreur n° " & Err.Number & vbCr & vbCr & _
Err.Description & Space(6), vbCritical + vbOKOnly, " Macro de MAJ du format nombre")
29 nov. 2017 à 11:25
2 mars 2007 à 16:35
'pour afficher les sources de données (ODBC).
'(http://www.vbfrance.com/codes/AFFICHER-INTERFACE-ODBC-POUR-CREER-SOURCE-DONNEE-DSN_32954.aspx)
Sub CreateCommandBar()
'Ajoute la barre de commandes "VB France"
On Error Resume Next
CommandBars("VB France").Delete
On Error GoTo 0
With CommandBars.Add("VB France")
With .Controls.Add(msoControlButton)
.Caption = " Source de données (ODBC) "
.OnAction = "DisplayODBCManager"
End With
With .Controls.Add(msoControlPopup)
.Caption = " Macros "
.BeginGroup = True
With .Controls.Add(msoControlButton)
.Caption = "Convertir en nombre (format standard)"
.OnAction = "ConvertStrToDbl"
End With
With .Controls.Add(msoControlButton)
.Caption = "Appliquer le format monétaire"
.BeginGroup = True
.OnAction = "ApplyCurrencyFormat"
End With
With .Controls.Add(msoControlButton)
.Caption = "Appliquer le format pourcentage"
.OnAction = "ApplyPercentageFormat"
End With
With .Controls.Add(msoControlButton)
.Caption = "Corriger les dates enregistrées au format anglais"
.BeginGroup = True
.OnAction = "ModifyDateFormat"
End With
End With
.Visible = True
End With
End Sub
2 mars 2007 à 12:00
Sub CreateCommandBar()
'Ajoute la barre d'outils "VB France"
On Error Resume Next
CommandBars("VB France").Delete
On Error GoTo 0
With CommandBars.Add(Name:="VB France")
With .Controls.Add(Type:=msoControlPopup)
.Caption = "Macros" + Space(25)
With .Controls.Add(msoControlButton)
.OnAction = "ConvertStrToDbl"
.Caption = "Convertir en nombre (format standard)"
End With
With .Controls.Add(msoControlButton)
.OnAction = "ApplyCurrencyFormat"
.Caption = "Appliquer le format monétaire"
.BeginGroup = True
End With
With .Controls.Add(msoControlButton)
.OnAction = "ApplyPercentageFormat"
.Caption = "Appliquer le format pourcentage"
End With
With .Controls.Add(msoControlButton)
.OnAction = "ModifyDateFormat"
.Caption = "Corriger les dates enregistrées au format anglais"
.BeginGroup = True
End With
End With
.Visible = True
End With
End Sub
2 mars 2007 à 11:43
Sub CreateCommandBar()
On Error Resume Next
CommandBars("BTD Consulting").Delete
On Error GoTo 0
With CommandBars.Add(Name:="VB France")
With .Controls.Add(Type:=msoControlPopup)
.Caption = "Macros" + Space(25)
.TooltipText = ""
With .Controls.Add(msoControlButton)
.OnAction = "ConvertStrToDbl"
.Caption = "Convertir en nombre (format standard)"
End With
With .Controls.Add(msoControlButton)
.FaceId = 0
.OnAction = "ApplyCurrencyFormat"
.Caption = "Appliquer le format monétaire"
.BeginGroup = True
End With
With .Controls.Add(msoControlButton)
.FaceId = 0
.OnAction = "ApplyPercentageFormat"
.Caption = "Appliquer le format pourcentage"
End With
With .Controls.Add(msoControlButton)
.FaceId = 0
.OnAction = "ModifyDateFormat"
.Caption = "Corriger les dates enregistrées au format anglais"
.BeginGroup = True
End With
End With
.Visible = True
End With
End Sub
6 févr. 2007 à 16:40
« Cent fois sur le métier, tu remettras ton ouvrage.»
30 janv. 2007 à 09:54
'Annule et remplace les exemples précédents en commentaire car il ne faut pas oublier de diviser ou multiplier par 100.
Sub setPercentageFormat()
'Affecte le format pourcentage à la plage sélectionnée
'Variables de traitement
Dim myNumber As Double
Dim myRange As Range
'Gestionnaire d'erreur
On Error GoTo Except
For Each myRange In Selection
With myRange
If Right(.Value, 1) = "%" Then
If IsNumeric(Left(.Value, Len(.Value) - 1)) Then
myNumber = Left(.Value, Len(.Value) - 1) / 100
.NumberFormat = "#,##0.00 %"
.Value = myNumber
End If
ElseIf IsNumeric(.Value) Then
myNumber = .Value * 100
.NumberFormat = "#,##0.00 %"
.Value = myNumber
End If
End With
Next
Exit Sub
Except:
'Boîte de dialogue : message d'erreur
Call MsgBox(vbCr & "Erreur n° " & Err.Number & vbCr & vbCr & _
Err.Description & Space(6), vbCritical + vbOKOnly, " Macro de MAJ du format pourcentage")
End Sub
29 janv. 2007 à 17:28
Sub setPercentageFormat()
'Affecte le format pourcentage à la plage sélectionnée
'Variables de traitement
Dim myNumber As Double
Dim myRange As Range
'Gestionnaire d'erreur
On Error GoTo Except
For Each myRange In Selection
With myRange
If Right(.Value, 1) = "%" Then
If IsNumeric(Left(.Value, Len(.Value) - 1)) Then
myNumber = Left(.Value, Len(.Value) - 1) / 100
.NumberFormat = "#,##0.00 %"
.Value = myNumber
End If
ElseIf IsNumeric(.Value) Then
myNumber = .Value / 100
.NumberFormat = "#,##0.00 %"
.Value = myNumber
End If
End With
Next
Exit Sub
Except:
'Boîte de dialogue : message d'erreur
Call MsgBox(vbCr & "Erreur n° " & Err.Number & vbCr & vbCr & _
Err.Description & Space(6), vbCritical + vbOKOnly, " Macro de MAJ du format pourcentage")
End Sub
29 janv. 2007 à 17:17
Sub setPercentageFormat()
'Affecte le format pourcentage à la plage sélectionnée
'Variables de traitement
Dim myNumber As Double
Dim myRange As Range
'Gestionnaire d'erreur
On Error GoTo Except
For Each myRange In Selection
With myRange
If Right(.Value, 1) = "%" Then
If IsNumeric(Left(.Value, Len(.Value) - 1)) Then
myNumber = Left(.Value, Len(.Value) - 1)
.NumberFormat = "#,##0.00 %"
.Value = myNumber
End If
ElseIf IsNumeric(.Value) Then
myNumber = .Value
.NumberFormat = "#,##0.00 %"
.Value = myNumber
End If
End With
Next
Exit Sub
Except:
'Boîte de dialogue : message d'erreur
Call MsgBox(vbCr & "Erreur n° " & Err.Number & vbCr & vbCr & _
Err.Description & Space(6), vbCritical + vbOKOnly, " Macro de MAJ du format pourcentage")
End Sub
29 janv. 2007 à 17:12
Sub setPercentageFormat()
'Affecte le format pourcentage à la plage sélectionnée
'Variables de traitement
Dim myNumber As Double
Dim myRange As Range
'Gestionnaire d'erreur
On Error GoTo Except
For Each myRange In Selection
With myRange
If Right(.Value, 1) = "%" Then
If IsNumeric(Left(.Value, Len(.Value) - 1)) Then
myNumber = Left(.Value, Len(.Value) - 1)
.NumberFormat = "#,##0.00 %"
.Value = myNumber
End If
End If
End With
Next
Exit Sub
Except:
'Boîte de dialogue : message d'erreur
Call MsgBox(vbCr & "Erreur n° " & Err.Number & vbCr & vbCr & _
Err.Description & Space(6), vbCritical + vbOKOnly, " Macro de MAJ du format nombre")
End Sub