Imbrication de conditions IF dans un select case
Bonjour,
J'ai un cas comme dans cette discussion Select Case avec plusieurs variables.
Voici mon
Code:
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
| Sub InsertExistingBuildingBlock()
Select Case ComboBoxDocType.ListIndex
Case Is = 0 'First item in list
If ListBoxCoC.Text = "General Comments" Then
AutoTextToBM "EVTBookMark01", ActiveDocument.AttachedTemplate, "GeneralComments"
End If
If ListBoxCoC.Text = "Specific Comments" Then
AutoTextToBM "EVTBookMark02", ActiveDocument.AttachedTemplate, "SpecificComments"
End If
Case Is = 1 'Second item in list
AutoTextToBM "EVTBookMark01", ActiveDocument.AttachedTemplate, "Table"
Case Else 'Nothing selected
End Select
End Sub
Public Sub AutoTextToBM(strbmName As String, oTemplate As Template, strAutotext As String)
'Graham Mayor - <a href="http://www.gmayor.com" target="_blank">http://www.gmayor.com</a> - Last updated - 17 Dec 2017
'strBMName is the name of the bookmark to fill
'oTemplate is the template with the autotext - probably ActiveDocument.AttachedTemplate
'strAutotext is the name of the autotext entry
Dim orng As Range
On Error GoTo lbl_Exit
With ActiveDocument
Set orng = .Bookmarks(strbmName).Range
Set orng = oTemplate.AutoTextEntries(strAutotext).Insert _
(Where:=orng, RichText:=True)
.Bookmarks.Add Name:=strbmName, Range:=orng
End With
lbl_Exit:
Exit Sub
End Sub |
Le deuxième "CASE" fonctionne mais le premier refuse obstinément d'insérer les building Blocks aux Bookmarks déterminés. Après quelques tâtonnements, je me suis aperçu que c'est la combinaison Case et IF qui bloque. Y a-t-il une solution pour parvenir à mes fins?
Merci.
P.