Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #31  
Old 08-21-2021, 04:50 PM
gorkac gorkac is offline Help with bookmarks in word. Windows 10 Help with bookmarks in word. Office 2019
Advanced Beginner
Help with bookmarks in word.
 
Join Date: Jul 2021
Posts: 62
gorkac is on a distinguished road
Default

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
Reply With Quote
  #32  
Old 08-22-2021, 12:41 AM
gmayor's Avatar
gmayor gmayor is offline Help with bookmarks in word. Windows 10 Help with bookmarks in word. Office 2019
Expert
 
Join Date: Aug 2014
Posts: 4,101
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 of
Default

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.
Attached Files
File Type: xlsx TERMINOS Y KILOMETROS.xlsx (68.4 KB, 7 views)
__________________
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
  #33  
Old 08-22-2021, 02:21 AM
gorkac gorkac is offline Help with bookmarks in word. Windows 10 Help with bookmarks in word. Office 2019
Advanced Beginner
Help with bookmarks in word.
 
Join Date: Jul 2021
Posts: 62
gorkac is on a distinguished road
Default

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).
Reply With Quote
  #34  
Old 08-22-2021, 03:08 AM
gorkac gorkac is offline Help with bookmarks in word. Windows 10 Help with bookmarks in word. Office 2019
Advanced Beginner
Help with bookmarks in word.
 
Join Date: Jul 2021
Posts: 62
gorkac is on a distinguished road
Default

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
Reply With Quote
  #35  
Old 08-22-2021, 04:21 AM
gorkac gorkac is offline Help with bookmarks in word. Windows 10 Help with bookmarks in word. Office 2019
Advanced Beginner
Help with bookmarks in word.
 
Join Date: Jul 2021
Posts: 62
gorkac is on a distinguished road
Default

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
Reply With Quote
  #36  
Old 08-22-2021, 04:45 AM
gorkac gorkac is offline Help with bookmarks in word. Windows 10 Help with bookmarks in word. Office 2019
Advanced Beginner
Help with bookmarks in word.
 
Join Date: Jul 2021
Posts: 62
gorkac is on a distinguished road
Default

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
Here the remaining code:
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
2.- The message does not show it if I enter a higher value:
Code:
 If lPK > 112.151 Then
MsgBox "Introduce un punto kilometrico menor que 112,151"
   End If
Reply With Quote
  #37  
Old 08-24-2021, 11:18 PM
Guessed's Avatar
Guessed Guessed is offline Help with bookmarks in word. Windows 10 Help with bookmarks in word. Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,932
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

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).
Attached Files
File Type: docm DemoSpanishHighways.docm (70.4 KB, 5 views)
File Type: xlsx SpanishHighway.xlsx (92.9 KB, 4 views)
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
  #38  
Old 08-31-2021, 09:56 PM
gorkac gorkac is offline Help with bookmarks in word. Windows 10 Help with bookmarks in word. Office 2019
Advanced Beginner
Help with bookmarks in word.
 
Join Date: Jul 2021
Posts: 62
gorkac is on a distinguished road
Default

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:
Originally Posted by gmayor View Post
You probably need something like the following, but if there are lots of these values as seems to be the case you would be better putting the codes and their values in an Excel worksheet and reading them from the worksheet.

Code:
Private Sub CommandButton2_Click()
Dim sVia As String
Dim lPK As String
    sVia = ComboVia.Text
    lPK = textPK.Value
    Select Case sVia
        Case Is = "A-68"
            If lPK > 81 And lPK < 85 Then
                Rellenar "termino", "Castejon"
                Rellenar "partido", "Tudela"
            End If
            If lPK > 84 And lPK < 99 Then
                Rellenar "termino", "Corella"
                Rellenar "partido", "Estella"
            End If
            If lPK > 98 And lPK < 113 Then
                Rellenar "termino", "Fontellas"
                Rellenar "partido", "Tafalla"
            End If
        Case Is = "NA-3010"
            If lPK > 20 And lPK < 25 Then
                Rellenar "termino", "Cortes"
                Rellenar "partido", "Tudela"
            End If
            If lPK > 24 And lPK < 35 Then
                Rellenar "termino", "Ribaforada"
                Rellenar "partido", "Tafalla"
            End If
            If lPK > 34 And lPK < 44 Then
                Rellenar "termino", "Novillas"
                Rellenar "partido", "Estella"
            End If
    End Select
lbl_Exit:
    Exit Sub
End Sub
Reply With Quote
  #39  
Old 08-31-2021, 11:39 PM
gmayor's Avatar
gmayor gmayor is offline Help with bookmarks in word. Windows 10 Help with bookmarks in word. Office 2019
Expert
 
Join Date: Aug 2014
Posts: 4,101
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 of
Default

The code you have used to insert text to the bookmark 'Termino' is e.g.
Code:
 Rellenar "termino", "Castejon"
You can either use a REF field to repeat the value from the bookmark, or simply write the same value to the new bookmark e.g.
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
Reply With Quote
  #40  
Old 09-01-2021, 04:17 AM
gorkac gorkac is offline Help with bookmarks in word. Windows 10 Help with bookmarks in word. Office 2019
Advanced Beginner
Help with bookmarks in word.
 
Join Date: Jul 2021
Posts: 62
gorkac is on a distinguished road
Default

Quote:
Originally Posted by gmayor View Post
The code you have used to insert text to the bookmark 'Termino' is e.g.
Code:
 Rellenar "termino", "Castejon"
You can either use a REF field to repeat the value from the bookmark, or simply write the same value to the new bookmark e.g.
Code:
 Rellenar "termino2", "Castejon"
Graham, the first option discarded, I have several hundred lines of code.
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.
Reply With Quote
  #41  
Old 09-01-2021, 04:50 AM
gmayor's Avatar
gmayor gmayor is offline Help with bookmarks in word. Windows 10 Help with bookmarks in word. Office 2019
Expert
 
Join Date: Aug 2014
Posts: 4,101
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 of
Default

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
Reply With Quote
  #42  
Old 09-01-2021, 06:59 AM
gorkac gorkac is offline Help with bookmarks in word. Windows 10 Help with bookmarks in word. Office 2019
Advanced Beginner
Help with bookmarks in word.
 
Join Date: Jul 2021
Posts: 62
gorkac is on a distinguished road
Default

Quote:
Originally Posted by gmayor View Post
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
Oh yeah, this works again.
A lot of thanks.
Reply With Quote
Reply

Thread Tools
Display Modes


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
Help with bookmarks in word. Deleting only all bookmarks contents not the bookmarks adilprodigy Word VBA 1 10-11-2017 01:31 PM
Help with bookmarks in word. Form updating Bookmarks - writes to the bookmarks multiple times PeterPlys Word VBA 13 01-14-2015 06:41 AM
Help with bookmarks in word. 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

Other Forums: Access Forums

All times are GMT -7. The time now is 05:46 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft