![]() |
|
#31
|
|||
|
|||
|
I have followed all the directions made by you. The problem is that I am not working an Excel. It's all for Word. I just need to know how to divide everything into modules
|
|
#32
|
||||
|
||||
|
The problem is that you should be working with Excel AND Word. The PDF file you supplied originally should be the basis for the Excel file you need to hold the data.
Unfortunately it doesn't convert well to Word and the Word version converts less well to Excel. However the attached will get you started. You can interrogate the Excel file to provide the data you want for your userform and/or document.
__________________
Graham Mayor - MS MVP (Word) (2002-2019) Visit my web site for more programming tips and ready made processes www.gmayor.com |
|
#33
|
|||
|
|||
|
I only need to structure by Modules what is contained in the form "formulario", Public Sub CommandButton1_Click, all the Cases. They are many.
And later, these modules will be called from CommandButton1 (This is what I can't do). The code works perfectly, but it gives me an error because it is too long ( Message: Compilation error. Procedure too long). |
|
#34
|
|||
|
|||
|
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
|
|
#35
|
|||
|
|||
|
I have already achieved it, within the form "formulario" I have been dividing with subs ...
Sub Aux1() ... end sub And works. I put the first two sub: Sub Aux1() and Sub Aux2() ... Code:
Sub Aux1()
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
If lPK > 1.326 And lPK <= 1.8 Then
Rellenar "termino", " Tudela"
Rellenar "partido", "Tudela"
End If
If lPK > 1.801 And lPK <= 1.845 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
If lPK > 1.846 And lPK <= 4.045 Then
Rellenar "termino", "Corella"
Rellenar "partido", "Tudela"
End If
If lPK > 4.046 And lPK <= 10.45 Then
Rellenar "termino", "Castejón"
Rellenar "partido", "Tudela"
End If
If lPK > 10.451 And lPK <= 14.75 Then
Rellenar "termino", "Valtierra"
Rellenar "partido", "Tudela"
End If
If lPK > 14.751 And lPK <= 19.25 Then
Rellenar "termino", "Cadreita"
Rellenar "partido", "Tudela"
End If
If lPK > 19.251 And lPK <= 26.375 Then
Rellenar "termino", "Villafranca"
Rellenar "partido", "Tudela"
End If
If lPK > 26.376 And lPK <= 29.925 Then
Rellenar "termino", "Marcilla"
Rellenar "partido", "Tafalla"
End If
If lPK > 29.926 And lPK <= 34.55 Then
Rellenar "termino", "Peralta"
Rellenar "partido", "Tafalla"
End If
If lPK > 34.551 And lPK <= 34.63 Then
MsgBox "Aqui debes rellenar manualmente el Término Municipal, pues coinciden los pk,s. Verifica si es Calzada Norte Marcilla o Calzada Sur Peralta"
Rellenar "partido", "Tafalla"
End If
If lPK > 34.631 And lPK <= 37.05 Then
Rellenar "termino", "Marcilla"
Rellenar "partido", "Tafalla"
End If
If lPK > 37.051 And lPK <= 37.6 Then
Rellenar "termino", "Fallces"
Rellenar "partido", "Tafalla"
End If
If lPK > 37.601 And lPK <= 47.85 Then
Rellenar "termino", "Olite"
Rellenar "partido", "Tafalla"
End If
If lPK > 47.851 And lPK <= 54.95 Then
Rellenar "termino", "Tafalla"
Rellenar "partido", "Tafalla"
End If
If lPK > 54.951 And lPK <= 54.99 Then
MsgBox "Aqui debes rellenar manualmente el Término Municipal, pues coinciden los pk,s. Verifica si es Calzada Norte Tafalla o Calzada Sur Pueyo"
Rellenar "partido", "Tafalla"
End If
If lPK > 54.991 And lPK <= 60.365 Then
Rellenar "termino", "Pueyo"
Rellenar "partido", "Tafalla"
End If
If lPK > 60.366 And lPK <= 60.765 Then
Rellenar "termino", "Leoz"
Rellenar "partido", "Tafalla"
End If
If lPK > 60.766 And lPK <= 62 Then
Rellenar "termino", "Garinoain"
Rellenar "partido", "Tafalla"
End If
If lPK > 62.001 And lPK <= 63.24 Then
Rellenar "termino", "Barasoain"
Rellenar "partido", "Tafalla"
End If
If lPK > 63.241 And lPK <= 66.285 Then
Rellenar "termino", "Oloriz"
Rellenar "partido", "Tafalla"
End If
If lPK > 66.286 And lPK <= 68.6 Then
Rellenar "termino", "Unzue"
Rellenar "partido", "Tafalla"
End If
If lPK > 68.601 And lPK <= 76.1 Then
Rellenar "termino", "Tiebas-Muruarte de Reta"
Rellenar "partido", "Aoiz"
End If
If lPK > 76.101 And lPK <= 82.34 Then
Rellenar "termino", "Elorz"
Rellenar "partido", "Aoiz"
End If
If lPK > 82.341 And lPK <= 83 Then
Rellenar "termino", "Aranguren"
Rellenar "partido", "Aoiz"
End If
If lPK > 83.001 And lPK <= 101.72 Then
Rellenar "termino", "Berrioplano"
Rellenar "partido", "Pamplona"
End If
If lPK > 101.721 And lPK <= 108.405 Then
Rellenar "termino", "Iza"
Rellenar "partido", "Pamplona"
End If
If lPK > 108.406 And lPK <= 112.15 Then
Rellenar "termino", "Araquil"
Rellenar "partido", "Pamplona"
End If
If lPK > 112.151 Then
MsgBox "Introduce un punto kilometrico menor que 112,151"
End If
'AP-68 AUTOPISTA VASCO--ARAGONESA'
Case Is = "AP-68"
Rellenar "denominacion", "Autopista Vasco-Aragonesa"
If lPK >= 0 And lPK <= 116.449 Then
MsgBox "Introduce un punto kilometrico mayor que 116,449"
End If
If lPK >= 166.901 And lPK <= 201.649 Then
MsgBox "Este pk no pertenece a Navarra"
End If
If lPK >= 116.5 And lPK <= 166.9 Then
Rellenar "termino", "Lodosa"
Rellenar "partido", "Estella"
End If
If lPK >= 201.65 And lPK <= 209.075 Then
Rellenar "termino", "Corella"
Rellenar "partido", "Tudela"
End If
If lPK > 209.076 And lPK <= 212.35 Then
Rellenar "termino", "Tudela"
Rellenar "partido", "Tudela"
End If
If lPK > 212.351 And lPK <= 218.425 Then
Rellenar "termino", "Murchante"
Rellenar "partido", "Tudela"
End If
If lPK > 218.425 And lPK <= 218.64 Then
Rellenar "termino", "Tudela"
Rellenar "partido", "Tudela"
End If
If lPK > 218.426 And lPK <= 220 Then
Rellenar "termino", "Cascante"
Rellenar "partido", "Tudela"
End If
If lPK > 220.001 And lPK <= 222.3 Then
Rellenar "termino", "Tudela"
Rellenar "partido", "Tudela"
End If
If lPK > 222.301 And lPK <= 227.435 Then
Rellenar "termino", "Fontellas"
Rellenar "partido", "Tudela"
End If
If lPK > 227.436 And lPK <= 229.94 Then
Rellenar "termino", "Ablitas"
Rellenar "partido", "Tudela"
End If
If lPK > 229.941 And lPK <= 232.46 Then
Rellenar "termino", "Ribaforada"
Rellenar "partido", "Tudela"
End If
If lPK > 232.461 And lPK <= 234.7 Then
Rellenar "termino", "Ablitas"
Rellenar "partido", "Tudela"
End If
If lPK > 234.701 And lPK <= 237.06 Then
Rellenar "termino", "Cortes"
Rellenar "partido", "Tudela"
End If
'A-1 AUTOVÍA DEL NORTE'
Case Is = "A-1"
Rellenar "denominacion", "Autovía del Norte"
If lPK >= 0 And lPK <= 391.699 Then
MsgBox "Introduce un punto kilometrico mayor que 391,699"
End If
If lPK >= 391.7 And lPK <= 394 Then
Rellenar "termino", "Ciordia"
Rellenar "partido", "Pamplona"
End If
If lPK > 394 And lPK <= 397.175 Then
Rellenar "termino", "Olazagutía"
Rellenar "partido", "Pamplona"
End If
If lPK > 397.175 And lPK <= 397.175 Then
Rellenar "termino", "Olazagutía"
Rellenar "partido", "Pamplona"
End If
If lPK > 397.176 And lPK <= 402.65 Then
Rellenar "termino", "Alsasua"
Rellenar "partido", "Pamplona"
End If
If lPK > 402.651 And lPK <= 403.95 Then
Rellenar "termino", "Olazagutía"
Rellenar "partido", "Pamplona"
End If
If lPK > 403.951 And lPK <= 404.175 Then 'Caso especial'
Rellenar "termino", "Alsasua"
Rellenar "partido", "Pamplona"
End If
If lPK > 404.176 And lPK <= 404.6 Then
Rellenar "termino", "Calzada Sur Olazagutía"
Rellenar "partido", "Pamplona"
End If
If lPK > 404.601 And lPK <= 405.45 Then
Rellenar "termino", "Alsasua"
Rellenar "partido", "Pamplona"
End If
'A-10 AUTOVIA DE LA BARRANCA'
Case Is = "A-10"
Rellenar "denominacion", "Autovía de la Barranca"
Rellenar "partido", "Pamplona"
If lPK >= 0 And lPK <= 7.525 Then
Rellenar "termino", "Araquil"
End If
If lPK >= 7.526 And lPK <= 7.825 Then
Rellenar "termino", "Irañeta"
End If
If lPK >= 7.826 And lPK <= 8.87 Then
Rellenar "termino", "Araquil"
End If
If lPK >= 8.871 And lPK <= 9.135 Then
Rellenar "termino", "Irañeta"
End If
If lPK >= 9.136 And lPK <= 13.335 Then
Rellenar "termino", "Uharte Araquil"
End If
If lPK >= 13.336 And lPK <= 15.055 Then
Rellenar "termino", "Arruazu"
End If
If lPK >= 15.056 And lPK <= 16.85 Then
Rellenar "termino", "Lakuntza"
End If
If lPK >= 16.851 And lPK <= 18.63 Then
Rellenar "termino", "Arbizu"
End If
If lPK >= 18.631 And lPK <= 22.35 Then
Rellenar "termino", "Etxarri Aranaz"
End If
If lPK >= 22.351 And lPK <= 24.16 Then
Rellenar "termino", "Bacaicoa"
End If
If lPK >= 24.161 And lPK <= 25.49 Then
Rellenar "termino", "Iturmendi"
End If
If lPK >= 25.491 And lPK <= 27.575 Then
Rellenar "termino", "Urdiain"
End If
If lPK >= 27.576 And lPK <= 29.785 Then
Rellenar "termino", "Alsasua"
End If
If lPK >= 29.786 Then
MsgBox "No existe este punto kilométrico en la Autovía de la Barranca"
End If
'A-12 AUTOVIA DEL CAMINO'
Case Is = "A-12"
Rellenar "denominacion", "Autovía del Camino"
If lPK >= 0 And lPK <= 4.19 Then
Rellenar "termino", "Pamplona"
Rellenar "partido", "Pamplona"
End If
If lPK >= 4.191 And lPK <= 6.66 Then
Rellenar "termino", "Zizur Mayor"
Rellenar "partido", "Pamplona"
End If
If lPK >= 6.661 And lPK <= 13.385 Then
Rellenar "termino", "Cizur"
Rellenar "partido", "Pamplona"
End If
If lPK >= 13.386 And lPK <= 14.165 Then
Rellenar "termino", "Uterga"
Rellenar "partido", "Pamplona"
End If
If lPK >= 14.166 And lPK <= 18.565 Then
Rellenar "termino", "Legarda"
Rellenar "partido", "Pamplona"
End If
If lPK >= 18.566 And lPK <= 20.165 Then
Rellenar "termino", "Obanos"
Rellenar "partido", "Pamplona"
End If
If lPK >= 20.166 And lPK <= 24.24 Then
Rellenar "termino", "Puente la Reina"
Rellenar "partido", "Pamplona"
End If
If lPK >= 24.241 And lPK <= 26.595 Then
Rellenar "termino", "Mañeru"
Rellenar "partido", "Estella"
End If
If lPK >= 26.596 And lPK <= 32.625 Then
Rellenar "termino", "Cirauqui"
Rellenar "partido", "Estella"
End If
If lPK >= 32.626 And lPK <= 36.49 Then
Rellenar "termino", "Villatuerta"
Rellenar "partido", "Estella"
End If
If lPK >= 36.491 And lPK <= 38.77 Then
Rellenar "termino", "Villatuerta"
Rellenar "partido", "Estella"
End If
If lPK >= 38.771 And lPK <= 41.44 Then
Rellenar "termino", "Estella"
Rellenar "partido", "Estella"
End If
If lPK >= 41.441 And lPK <= 44.01 Then
Rellenar "termino", "Ayegui"
Rellenar "partido", "Estella"
End If
If lPK >= 44.011 And lPK <= 47.6 Then
Rellenar "termino", "Iguzkiza"
Rellenar "partido", "Estella"
End If
If lPK >= 47.601 And lPK <= 48.32 Then
Rellenar "termino", "Villamayor de Monjardin"
Rellenar "partido", "Estella"
End If
If lPK >= 48.321 And lPK <= 50.45 Then
Rellenar "termino", "Iguzkiza"
Rellenar "partido", "Estella"
End If
If lPK >= 50.451 And lPK <= 53.55 Then
Rellenar "termino", "Luquin"
Rellenar "partido", "Estella"
End If
If lPK >= 53.551 And lPK <= 54.14 Then
Rellenar "termino", "Barbarin"
Rellenar "partido", "Estella"
End If
If lPK >= 54.141 And lPK <= 55.565 Then
Rellenar "termino", "Villamayor de Monjardin"
Rellenar "partido", "Estella"
End If
If lPK >= 55.566 And lPK <= 57.21 Then
Rellenar "termino", "Barbarin"
Rellenar "partido", "Estella"
End If
If lPK >= 57.211 And lPK <= 61.215 Then
Rellenar "termino", "Los Arcos"
Rellenar "partido", "Estella"
End If
If lPK >= 61.216 And lPK <= 61.36 Then
Rellenar "termino", "Piedramillera"
Rellenar "partido", "Estella"
End If
If lPK >= 61.361 And lPK <= 61.835 Then
Rellenar "termino", "Los Arcos"
Rellenar "partido", "Estella"
End If
If lPK >= 61.836 And lPK <= 62.115 Then
Rellenar "termino", "Piedramillera"
Rellenar "partido", "Estella"
End If
If lPK >= 62.116 And lPK <= 63.085 Then
Rellenar "termino", "Los Arcos"
Rellenar "partido", "Estella"
End If
If lPK >= 63.086 And lPK <= 63.39 Then
Rellenar "termino", "Piedramillera"
Rellenar "partido", "Estella"
End If
If lPK >= 63.391 And lPK <= 64.4 Then
Rellenar "termino", "El Busto"
Rellenar "partido", "Estella"
End If
If lPK >= 64.401 And lPK <= 67.185 Then
Rellenar "termino", "Sansol"
Rellenar "partido", "Estella"
End If
If lPK >= 67.186 And lPK <= 69.58 Then
Rellenar "termino", "Torres del Río"
Rellenar "partido", "Estella"
End If
If lPK >= 69.581 And lPK <= 70.81 Then
Rellenar "termino", "Armañanzas"
Rellenar "partido", "Estella"
End If
If lPK >= 70.811 And lPK <= 72.31 Then
Rellenar "termino", "Bargota"
Rellenar "partido", "Estella"
End If
If lPK >= 72.31 And lPK <= 76.15 Then
Rellenar "termino", "Viana"
Rellenar "partido", "Estella"
End If
If lPK > 76.151 Then
MsgBox "Introduce un punto kilometrico menor que 76,151"
End If
'A-15 RONDA DE PAMPLONA OESTE'
Case Is = "A-15 Ronda de Pamplona Oeste"
Rellenar "denominacion", "Ronda de Pamplona Oeste"
If lPK >= 83 And lPK <= 83.375 Then
Rellenar "termino", "Aranguren"
Rellenar "partido", "Aoiz"
End If
If lPK >= 83.376 And lPK <= 83.41 Then
MsgBox "Aqui debes rellenar manualmente el Término Municipal y el Partido Judicial, pues coinciden los pk,s. Verifica si es Calzada Norte Aranguren (Partido Judicial Aoiz) o Calzada Sur Galar (Partido Judicial Pamplona)"
End If
If lPK >= 83.411 And lPK <= 86.365 Then
Rellenar "termino", "Galar"
Rellenar "partido", "Pamplona"
End If
If lPK >= 86.366 And lPK <= 87.325 Then
Rellenar "termino", "Cizur"
Rellenar "partido", "Pamplona"
End If
If lPK >= 87.326 And lPK <= 90.38 Then
Rellenar "termino", "Zizur Mayor"
Rellenar "partido", "Pamplona"
End If
If lPK >= 90.381 And lPK <= 92.35 Then
Rellenar "termino", "Olza"
Rellenar "partido", "Pamplona"
End If
If lPK >= 92.351 And lPK <= 94.9 Then
Rellenar "termino", "Orcoyen"
Rellenar "partido", "Pamplona"
End If
If lPK >= 94.901 And lPK <= 95.07 Then
MsgBox "Aqui debes rellenar manualmente el Término Municipal, pues coinciden los pk,s. Verifica si es Calzada Norte Pamplona o Calzada Sur Orcoyen."
Rellenar "partido", "Pamplona"
End If
If lPK >= 95.071 And lPK <= 96 Then
Rellenar "termino", "Berrioplano"
Rellenar "partido", "Pamplona"
End If
If lPK > 96 Then
MsgBox "Introduce un punto kilometrico MENOR que 96."
End If
'A-15 AUTOVIA DE LEITZARAN'
Case Is = "A-15 Autovía de Leitzarán"
Rellenar "denominacion", "Autovía de Leitzarán"
Rellenar "partido", "Pamplona"
If lPK >= 112.15 And lPK <= 113 Then
Rellenar "termino", "Araquil"
End If
If lPK >= 113.001 And lPK <= 114.275 Then
Rellenar "termino", "Irurzun"
End If
If lPK >= 114.276 And lPK <= 114.675 Then
MsgBox "Aqui debes rellenar manualmente el Término Municipal, pues coinciden los pk,s. Verifica manualmente si es Calzada Norte Irurzun ó Calzada Sur Araquil"
End If
If lPK >= 114.676 And lPK <= 115.65 Then
Rellenar "termino", "Irurzun"
End If
If lPK >= 115.651 And lPK <= 120.2 Then
Rellenar "termino", "Imoz"
End If
If lPK >= 120.201 And lPK <= 124.875 Then
Rellenar "termino", "Larraun"
End If
If lPK >= 124.876 And lPK <= 128.28 Then
Rellenar "termino", "Lecumberri"
End If
If lPK >= 128.281 And lPK <= 135.235 Then
Rellenar "termino", "Larraun"
End If
If lPK >= 135.236 And lPK <= 139.07 Then
Rellenar "termino", "Areso"
End If
If lPK >= 139.071 And lPK <= 139.885 Then
Rellenar "termino", "Leiza"
End If
If lPK >= 139.886 Then
MsgBox "Introduce un punto kilometrico MENOR que 139,886."
End If
'A-21 AUTOVIA DEL PIRINEO'
Case Is = "A-21"
Rellenar "denominacion", "Autovía del Pirineo"
Rellenar "partido", "Aoiz"
If lPK >= 6.799 Then
MsgBox "Introduce un punto kilometrico MAYOR que 6,799."
End If
If lPK >= 6.8 And lPK <= 13.84 Then
Rellenar "termino", "Noain-Valle de Elorz"
End If
If lPK >= 13.841 And lPK <= 20.66 Then
Rellenar "termino", "Monreal"
End If
If lPK >= 20.661 And lPK <= 28.5 Then
Rellenar "termino", "Ibargoiti"
End If
If lPK >= 28.501 And lPK <= 29.865 Then
Rellenar "termino", "Lumbier"
End If
If lPK >= 29.866 And lPK <= 34.09 Then
Rellenar "termino", "Urraul Bajo"
End If
If lPK >= 34.091 And lPK <= 34.092 Then '¡¡¡REVISAR ESTOS TRES ULTIMOS TERMINOS!!! FALTA lumbier, Liedena y Yesa, NO TIENEN PK'
Rellenar "termino", "Lumbier"
End If
'A-68 AUTOVIA DEL EBRO'
Case Is = "A-68"
Rellenar "denominacion", "Autovia del Ebro"
If lPK >= 0 And lPK <= 82.774 Then
MsgBox "Introduce un punto kilometrico mayor que 82,774"
End If
If lPK >= 82.775 And lPK <= 84.49 Then
Rellenar "termino", "Castejon"
Rellenar "partido", "Tudela"
End If
If lPK > 84.491 And lPK <= 98.96 Then
Rellenar "termino", "Tudela"
Rellenar "partido", "Tudela"
End If
If lPK > 98.961 And lPK <= 104.335 Then
Rellenar "termino", "Fontellas"
Rellenar "partido", "Tudela"
End If
If lPK > 104.336 And lPK <= 108.915 Then
Rellenar "termino", "Ribaforada"
Rellenar "partido", "Tudela"
End If
If lPK > 108.916 And lPK <= 111.05 Then
Rellenar "termino", "Buñuel"
Rellenar "partido", "Tudela"
End If
If lPK > 111.051 And lPK <= 116.85 Then
Rellenar "termino", "Fontellas"
Rellenar "partido", "Tudela"
End If
If lPK >= 116.851 Then
MsgBox "Introduce un punto kilometrico MENOR que 116,851"
End If
End Select
End Sub
Sub Aux2()
Select Case sVia
'PA-30 RONDA DE PAMPLONA'
Case Is = "PA-30"
Rellenar "denominacion", "Ronda de Pamplona"
If lPK >= 0 And lPK <= 4.225 Then
Rellenar "termino", "Aranguren"
Rellenar "partido", "Aoiz"
End If
If lPK >= 4.226 And lPK <= 5.15 Then
Rellenar "termino", "Pamplona"
Rellenar "partido", "Pamplona"
End If
If lPK >= 5.151 And lPK <= 7.885 Then
Rellenar "termino", "Egues"
Rellenar "partido", "Aoiz"
End If
If lPK >= 7.886 And lPK <= 9.175 Then
Rellenar "termino", "Huarte"
Rellenar "partido", "Aoiz"
End If
If lPK >= 9.176 And lPK <= 10.3 Then
Rellenar "termino", "Esteribar"
Rellenar "partido", "Aoiz"
End If
If lPK >= 10.301 And lPK <= 10.45 Then
Rellenar "termino", "Huarte"
Rellenar "partido", "Aoiz"
End If
If lPK >= 10.451 And lPK <= 13.275 Then
Rellenar "termino", "Ezcabarte"
Rellenar "partido", "Pamplona"
End If
If lPK >= 13.276 And lPK <= 13.87 Then
Rellenar "termino", "Pamplona"
Rellenar "partido", "Pamplona"
End If
If lPK >= 13.871 And lPK <= 15.2 Then
MsgBox "ATENCIÓN, verifica las siguientes opciones..." & vbNewLine & vbNewLine & "Calzada Arazuri Burlada, pk 13,87 a pk 14,13" & vbNewLine & vbNewLine & "Calzada Noain Burlada, pk 13,87 a pk 14,2" & vbNewLine & vbNewLine & "Calzada Arazuri Pamplona, pk 14,13 a pk 15,2" & vbNewLine & vbNewLine & "Calzada Noain Burlada, pk 14,2 a pk 15,2"
'MEJORAR ESTA PARTE CON MENSAJE USERFORM Y SELECCIONES'
Rellenar "partido", "Pamplona"
End If
If lPK >= 15.201 And lPK <= 16.825 Then
Rellenar "termino", "Ansoain"
Rellenar "partido", "Pamplona"
End If
If lPK >= 16.826 And lPK <= 18.1 Then
Rellenar "termino", "Berrioplano"
Rellenar "partido", "Pamplona"
End If
If lPK >= 18.101 And lPK <= 20.83 Then
MsgBox "Aqui debes rellenar manualmente el Término Municipal, pues coinciden algunos pk,s." & vbNewLine & vbNewLine & "Calzada Arazuri Berriozar pk 18,100 a 18,700" & vbNewLine & vbNewLine & "Pamplona pk 18,100 a 20,830"
Rellenar "partido", "Pamplona"
End If
If lPK >= 20.831 And lPK <= 23.2 Then
Rellenar "termino", "Orcoyen"
Rellenar "partido", "Pamplona"
End If
If lPK >= 23.201 And lPK <= 23.43 Then
Rellenar "termino", "Orcoyen"
Rellenar "partido", "Pamplona"
End If
If lPK >= 23.431 Then
MsgBox "Introduce un punto kilometrico MENOR que 23,431"
End If
'PA-31 ACCESO DE PAMPLONA SUR Y AEROPUERTO'
Case Is = "PA-31"
Rellenar "denominacion", "Acceso de Pamplona Sur y Aeropuerto"
If lPK >= 0 And lPK <= 1.75 Then
Rellenar "termino", "Galar"
Rellenar "partido", "Pamplona"
End If
If lPK >= 1.751 And lPK <= 2.19 Then
MsgBox "Aqui debes rellenar manualmente el Término Municipal y el Partido Judicial, pues coinciden algunos pk,s." & vbNewLine & vbNewLine & "Calzada Noain Galar pk 1,750 a 2,190 (Partido Judicial Pamplona)" & vbNewLine & vbNewLine & "Calzada Pamplona Aranguren pk 1,750 a 2,025 (Partido Judicial Aoiz)"
End If
If lPK >= 2.19 And lPK <= 3.6 Then
Rellenar "termino", "Noain-Valle de Elorz"
Rellenar "partido", "Aoiz"
End If
If lPK >= 1.751 Then
MsgBox "Introduce un punto kilometrico MENOR que 1,751"
End If
'PA-32 ACCESO DE PAMPLONA SURESTE'
Case Is = "PA-32"
Rellenar "denominacion", "Acceso de Pamplona Sureste2"
If lPK >= 0 And lPK <= 0.425 Then
Rellenar "termino", "Galar"
Rellenar "partido", "Pamplona"
End If
If lPK >= 0.426 Then
MsgBox "Introduce un punto kilometrico MENOR que 0,426"
End If
'PA-33 ACCESO DE PAMPLONA ESTE'
Case Is = "PA-33"
Rellenar "denominacion", "Acceso de Pamplona Este"
If lPK >= 0 And lPK <= 0.095 Then
Rellenar "termino", "Pamplona"
Rellenar "partido", "Pamplona"
End If
If lPK >= 0.096 And lPK <= 0.38 Then
MsgBox "Aqui debes rellenar manualmente el Término Municipal, pues coinciden algunos pk,s." & vbNewLine & vbNewLine & "Calzada Izda Burlada pk 0,095 a 0,380" & vbNewLine & vbNewLine & "Calzada Dcha Pamplona pk 0,095 a 0,380"
Rellenar "partido", "Pamplona"
End If
If lPK >= 0.38 And lPK <= 0.95 Then
Rellenar "termino", "Egues"
End If
'PA-34 ACCESO DE PAMPLONA OESTE'
Case Is = "PA-34"
Rellenar "denominacion", "Acceso de Pamplona Oeste"
Rellenar "partido", "Pamplona"
If lPK >= 0 And lPK <= 1.165 Then
MsgBox "Aqui debes rellenar manualmente el Término Municipal, pues coinciden algunos pk,s." & vbNewLine & vbNewLine & "Calzada Izda Pamplona pk 0,000 a 1,165" & vbNewLine & vbNewLine & "Calzada Dcha Berriozar pk 0,000 a 1,165"
End If
If lPK >= 1.165 And lPK <= 2.7 Then
Rellenar "termino", "Berrioplano"
End If
End Select
End Sub
|
|
#36
|
|||
|
|||
|
Aaargh...
Two problems appear. 1.- The bookmarks "termino" and "partido" are not filled. Code:
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
Code:
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
Public Sub CommandButton1_Click() 'BOTON Aceptar'
' Uso la funcion Rellenar
Rellenar "via", cbovia.Text ' Asigno valor introducido en combo cbovia
Rellenar "kilometro", txtpk.Text ' Asigno valor en textbox kilometro
Dim sVia As String
Dim lPK As String
sVia = cbovia.Text
lPK = txtpk.Value
lbl_Exit:
Exit Sub
End Sub
Code:
If lPK > 112.151 Then MsgBox "Introduce un punto kilometrico menor que 112,151" End If |
|
#37
|
||||
|
||||
|
Have a look at this demonstration version. The data is embedded in a customXML file and the code reads it when required. Note that this avoids the need for a userform although the code could still be adapted if that is what you need.
The Word file is standalone for operation with the current dataset but if you need to update the xml, you will want to use the Excel file which was based on the data that Graham extracted from your PDF. In the Excel file, you can right click on a table and choose XML > Export to create the xml file which Word can make use of (via the update macro you can read about in the Word file).
__________________
Andrew Lockton Chrysalis Design, Melbourne Australia |
|
#38
|
|||
|
|||
|
Hi Mr. Mayor. I need a last favor.
In the same document, there are parts to fill in with the same bookmarks, but Word does not allow repeating the name of the bookmarks "termino", and so on. What lines can I add so that I fill in a new bookmark named "termino2", for example, what is filled in the marker "termino"? Quote:
|
|
#39
|
||||
|
||||
|
The code you have used to insert text to the bookmark 'Termino' is e.g.
Code:
Rellenar "termino", "Castejon" Code:
Rellenar "termino2", "Castejon"
__________________
Graham Mayor - MS MVP (Word) (2002-2019) Visit my web site for more programming tips and ready made processes www.gmayor.com |
|
#40
|
|||
|
|||
|
Quote:
Second option, is there not a line of code that validates if a bookmark has been filled in, for example "termino" and if so, fill in the bookmark "termino2"? It is that I have tried to use REF but it does not work for me. |
|
#41
|
||||
|
||||
|
OK after filling in 'termino' run the following code
Code:
If Not ActiveDocument.Bookmarks("termino").Range.Text = "" Then
Rellenar "termino2", ActiveDocument.Bookmarks("termino").Range.Text
End If
__________________
Graham Mayor - MS MVP (Word) (2002-2019) Visit my web site for more programming tips and ready made processes www.gmayor.com |
|
#42
|
|||
|
|||
|
Quote:
A lot of thanks. |
|
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Saving a word doc as a pdf with bookmarks | MimiCush | Word | 10 | 03-26-2018 01:51 PM |
Deleting only all bookmarks contents not the bookmarks
|
adilprodigy | Word VBA | 1 | 10-11-2017 01:31 PM |
Form updating Bookmarks - writes to the bookmarks multiple times
|
PeterPlys | Word VBA | 13 | 01-14-2015 06:41 AM |
selecting ms word bookmarks using vba
|
dnc | Word VBA | 4 | 05-10-2013 04:58 PM |
| word 2007 bookmarks | Dawn | Word | 0 | 07-14-2009 01:00 PM |