Bonjour à tous,

Dans le code ci-dessous (7ème et 8 ème lignes) , je souhaite utiliser le nom du présent fichier excel dans l'intitulé du Label1. Si je ne fais rien, le nom du fichier s'affiche avec l'extension (exemple : Bon de Livraison N° 57.xltm). Je voudrais donc supprimer ".xltm" pour ne garder que le nom usuel du fichier.

Pour l'instant, j'ai donc pris le parti de sélectionner les 22 premiers caractères de la chaîne. Cela reste valable tant que le numéro de bon est compris entre 10 et 99. Cette solution ne paraît donc pas satisfaisante.

Pourriez-vous me conseiller pour supprimer les 5 derniers caractères : .xltm.

Je vous en remercie par avance,
Très cordialement,
Maurice

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
Private Sub UserForm_Activate()
   Application.DisplayFullScreen = True
        Me.Width = Application.Width
        Me.Height = Application.Height
        Me.Left = 0
        Me.Top = 0
    If Right(ThisWorkbook.Name, 4) <> "xltm" Then
       If ActiveSheet.PageSetup.CenterHeader <> "" Then
                Label1.Caption = "ÉTABLISSEMENT DU " & Left(ThisWorkbook.Name, 22)
                Label1.Left = 260
                Frame1.Caption = "ETABLISSEMENT DES BONS"
                Frame1.ForeColor = &HFF0000
                Frame1.Left = 360
                CommandButton1.Enabled = True
                CommandButton2.Enabled = True
                CommandButton3.Enabled = True
                CommandButton4.Enabled = False
                CommandButton5.Enabled = False
                CommandButton6.Enabled = False
                CommandButton7.Enabled = False
        Else
                Label1.Caption = "VOUS ALLEZ ÉTABLIR UN BON DE COMMANDE"
                Label1.Left = 260
                Frame1.Caption = "ETABLISSEMENT DES BONS"
                Frame1.ForeColor = &HFF0000
                Frame1.Left = 360
                CommandButton1.Enabled = True
                CommandButton2.Enabled = True
                CommandButton3.Enabled = True
                CommandButton4.Enabled = False
                CommandButton5.Enabled = False
                CommandButton6.Enabled = False
                CommandButton7.Enabled = False
        End If
    Else
                Label1.Caption = "VOUS ALLEZ GERER VOS PRODUITS"
                Label1.Left = 260
                Frame1.ForeColor = &HFF&
                Frame1.Left = 360
                Frame1.Caption = "GESTION COMMERCIALE"
                CommandButton1.Enabled = False
                CommandButton2.Enabled = False
                CommandButton3.Enabled = False
                CommandButton4.Enabled = True
                CommandButton5.Enabled = True
                CommandButton6.Enabled = True
                CommandButton7.Enabled = True
    End If
End Sub