View Single Post
 
Old 08-17-2021, 08:36 PM
gmayor's Avatar
gmayor gmayor is offline Windows 10 Office 2019
Expert
 
Join Date: Aug 2014
Posts: 4,144
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

Quote:
Originally Posted by gorkac View Post
Is this that you just wrote possible to do with?
https://www.gmayor.com/insert_content_control_addin.htm
The code I posted uses bookmarks as requested. If you want to use content controls then

Code:
Private Sub CommandButton2_Click()
Dim oCC As ContentControl
Dim sVia As String, lPK As String, sTermPart As String, arr() As String
    sVia = ComboVia.Text
    lPK = textPK.value

    Select Case sVia
        Case Is = "A-68"
            If lPK < 85 Then
                sTermPart = "Castejon|Tudela"
            ElseIf lPK < 99 Then
                sTermPart = "Corella|Estella"
            Else
                sTermPart = "Fontellas|Tafalla"
            End If
        Case Is = "NA-3010"
            If lPK < 25 Then
                sTermPart = "Cortes|Tudela"
            ElseIf lPK < 35 Then
                sTermPart = "Ribaforada|Tafalla"
            Else
                sTermPart = "Novillas|Estella"
            End If
    End Select
    If UBound(arr) > 0 Then
        arr = Split(sTermPart, "|")
        For Each oCC In ActiveDocument.ContentControls
            Select Case oCC.Title
                Case Is = "termino"
                    oCC.Range.Text = arr(0)
                Case Is = "partido"
                    oCC.Range.Text = arr(1)
            End Select
        Next oCC
    End If
lbl_Exit:
    Set oCC = Nothing
    Exit Sub
End Sub
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote