This is where I need to divide the Case sVia, in modules:
Module1: from Case AP-15 until Case NA-134, for example. (about 100 cases)
Module2: from Case NA-135 until Case NA-236.(another 100 cases)
Module3: from Case NA-237 until Case NA-351.(another 100 cases)
etc.
Then, from the form "formulario", call those Modules.
So that it looks for the case and if it is, the Rellenar procedure works.
And so it will allow me to compile.
It is understood?
Code:
Public Sub CommandButton1_Click() 'BOTON Aceptar'
' Asignar valores de la caja de texto y combo a sus marcadores
' Uso la funcion Rellenar
Rellenar "via", cbovia.Text
Rellenar "kilometro", txtpk.Text
Dim sVia As String
Dim lPK As String
sVia = cbovia.Text
lPK = txtpk.Value
Select Case sVia
' ******* AP-15 AUTOPISTA DE NAVARRA ******* '
Case Is = "AP-15"
Rellenar "denominacion", "Autopista de Navarra"
If lPK >= 0 And lPK <= 1.225 Then
Rellenar "termino", "Corella"
Rellenar "partido", "Tudela"
End If
If lPK > 1.226 And lPK <= 1.325 Then
MsgBox "Aqui debes rellenar manualmente el Término Municipal, pues coinciden los pk,s. Verifica si es Calzada Norte Tudela o Calzada Sur Corella"
Rellenar "partido", "Tudela"
End If..
.
.
.
.
.
.
.
.
.
'6000 more lines'
.
.
.
.
.
.
.
' ******* NA-4410 BERA DE BIDASOA ******* '
Case Is = "NA-4410"
Rellenar "denominacion", "BERA DE BIDASOA"
Rellenar "partido", "Pamplona"
If lPK >= 0 And lPK < 5 Then
Rellenar "termino", "Vera de Bidasoa"
End If
If lPK >= 5.001 Then
MsgBox "Introduce un punto kilometrico MENOR que 5,001"
End If
' ******* NA-4445 ARRAZKAZAN (BARRIO) ******* '
Case Is = "NA-4445"
Rellenar "denominacion", "ARRAZKAZAN (BARRIO)"
Rellenar "partido", "Pamplona"
If lPK >= 0 And lPK < 1.48 Then
Rellenar "termino", "Baztan"
End If
If lPK >= 1.481 Then
MsgBox "Introduce un punto kilometrico MENOR que 1,481"
End If
End Select
lbl_Exit:
Exit Sub
End Sub
Public Sub Rellenar(strNombreMarcador As String, strValor As String)
'Gorka Cuairan. Función que rellena marcadores
Dim Rng As Range
With ActiveDocument
On Error GoTo lbl_Exit
Set Rng = .Bookmarks(strNombreMarcador).Range
Rng.Text = strValor
Rng.Bookmarks.Add strNombreMarcador
End With
lbl_Exit:
Set Rng = Nothing
Exit Sub
End Sub
Private Sub Userform_Activate() 'FORMULARIO, CARGA VIA
Call Carreteras.CargarCarreteras(cbovia)
End Sub