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
|
Function coupe2car(acouper)
'
Dim Tabl() As String
Dim Nom As String
Tabl = Split(acouper, "\")
Nom = ""
If UBound(Tabl) >= 1 Then
For I = 0 To UBound(Tabl) - 1
Nom = Nom & Left(Tabl(I), 2) & "\"
Next I
End If
'Debug.Print acouper, Nom
coupe2car = Nom
End Function
Sub traccia()
Dim monparc As String, parcabr As String, salvatore As String
monparc = ActiveDocument.FullName
salvatore = Application.UserInitials
salvatore = InputBox("Confermare iniziali di chi salva: ", "Iniziali", salvatore)
parcabr = coupe2car(monparc)
NouvPropAvecTest (parcabr & " (" & salvatore & ")")
Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, Text:= _
"DOCPROPERTY MaProp ", PreserveFormatting:=True
End Sub
Sub NouvPropAvecTest(MaVar As String)
On Error GoTo Ajout
If Not (IsNull(ActiveDocument.CustomDocumentProperties("MaProp").Value)) Then
ActiveDocument.CustomDocumentProperties("MaProp").Value = MaVar
End If
Ajout:
Select Case Err.Number
Case "5"
ActiveDocument.CustomDocumentProperties.Add Name:="MaProp", LinkToContent:=False, Value:=MaVar, Type:=msoPropertyTypeString
Case "0"
Exit Sub
Case Else
MsgBox "Erreur non gérée" & vbCrLf & Err.Number & vbCrLf & Err.Description
End Select
End Sub |
Partager