Hi All,
I'm rather a novice at VBA, but I have to create some basic macros for a client in Word. What I need to do that I can't figure out is insert some text automatically whenever a certain style sheet is applied. Inserting the text is a breeze, but I can't figure out what sort of If statement (if that is what is called for) might connect application of the style to running the code to insert the text. Below is one attempt, it may show the direction I'm going in (remember, I have absolutely no idea what I'm doing...)
Many thanks in advance
If Style = "ANNEX" Then
Selection.Style = ActiveDocument.Styles("ANNEX")
Selection.TypeText Text:=Chr(11)
Selection.Font.Bold = wdToggle
Selection.TypeText Text:="(Informative)" & Chr(11) & Chr(11)
Selection.Font.Bold = wdToggle
Selection.TypeText Text:="Annex Title"
End If
End Sub
I'm rather a novice at VBA, but I have to create some basic macros for a client in Word. What I need to do that I can't figure out is insert some text automatically whenever a certain style sheet is applied. Inserting the text is a breeze, but I can't figure out what sort of If statement (if that is what is called for) might connect application of the style to running the code to insert the text. Below is one attempt, it may show the direction I'm going in (remember, I have absolutely no idea what I'm doing...)
Many thanks in advance
If Style = "ANNEX" Then
Selection.Style = ActiveDocument.Styles("ANNEX")
Selection.TypeText Text:=Chr(11)
Selection.Font.Bold = wdToggle
Selection.TypeText Text:="(Informative)" & Chr(11) & Chr(11)
Selection.Font.Bold = wdToggle
Selection.TypeText Text:="Annex Title"
End If
End Sub