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 50 51
| 'Methode creation variable
Sub creationVariable()
On Error Resume Next
ActiveDocument.Variables.Add Name:="reqNum", Value:=0
Select Case Err.Number
Case "5903"
ActiveDocument.Variables(reqNum).Value = 0
Case Else
Exit Sub
End Select
End Sub
'Methode mise à jour valeur de la variable
Sub addVariable(stValue As Long)
On Error Resume Next
ActiveDocument.Variables.Add Name:="reqNum", Value:=stValue
Select Case Err.Number
Case "5903"
ActiveDocument.Variables(reqNum).Value = stValue
Case Else
Exit Sub
End Select
End Sub
'Methode increment variable
Sub incrementreqNum()
Static reqNum As Long 'Déclarer reqNum comme une variable de type Entier Long
ActiveDocument.Variables("reqNum").Value = ActiveDocument.Variables("reqNum").Value + 1
End Sub
'Methode init variable
Sub initreqNum()
Static reqNum As Long 'Déclarer reqNum comme une variable de type Entier Long
ActiveDocument.Variables("reqNum").Value = 0
End Sub
'Methode pour initialiser le Tag à une valeur désirée
Sub setValue()
Selection.HomeKey wdStory
Static myNumber As Long
myNumber = InputBox("Value to initialize the Requirement number :", "Set the Requirement value")
ActiveDocument.Variables("reqNum").Value = myNumber
End Sub
'Main
Sub addTag()
Dim myTag As String
Static maVariable As Long
maVariable = ActiveDocument.Variables("reqNum").Value
addVariable (maVariable)
incrementreqNum
myTag = "[MonTag_" & maVariable & "]"
Selection.TypeText (myTag)
End Sub |
Partager