XL 2013 Mettre le mois en anglais

geekpok

XLDnaute Nouveau
Bonjour,

J'ai une macro et dans cette macro je demande d'ouvrir un fichier par rapport au mois actuel et ce fichier a comme nom une partie du nom fixe et l'autre change avec le mois en cours. (exemple du com de fichier pour ce mois-ci "Active Parts October 2020 - NS.xls").
Le problème est que cela fonctionne sur un poste ou le windows est en anglais car le fichier est en anglais mais pas sur un poste en Français car il ne reconnait pas la date.

Voici ma macro pour ce fichier:

Dim Path_AP As String
Dim File_AP As String
Dim Current_Month As String
Dim Current_Year As Integer


Path_AP = "lien du fichier"
Current_Month = MonthName(Month(Date))
Current_Year = Year(Date)

File_AP = "Active Parts " & Current_Month & " " & Current_Year & " - NS.xls"

If Dir(Path_AP & "\" & File_AP) = "" Then
MsgBox ("Le fichier " & File_AP & " n'est pas présent dans le répertoire " & Path_AP)
Exit Sub
Else
Workbooks.Open (Path_AP & "\" & File_AP), ReadOnly:=True

Comment je peux dire à ma macro de regarder la date actuel (Current Month) et de la convertir en anglais ?
 

sylvanu

XLDnaute Barbatruc
Supporter XLD
Bonjour Geekpok,
Une solution bestiale mais efficace, utilisez un array :
VB:
Sub Essai()
    Dim Path_AP As String, File_AP As String, Current_Month As String, Current_Year As Integer, Mois()

    Mois = Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December")

    Path_AP = "lien du fichier"
    Current_Month = Mois(Month(Date) - 1)
    Current_Year = Year(Date)
    File_AP = "Active Parts " & Current_Month & " " & Current_Year & " - NS.xls"
End Sub
 

Discussions similaires

Statistiques des forums

Discussions
312 211
Messages
2 086 294
Membres
103 171
dernier inscrit
clemm