Forum Discussion

Jorge5445's avatar
Jorge5445
Copper Contributor
Aug 02, 2023
Solved

I need help with this code

Hi all I use this piece of code to go to any page of my word document Dim pagina As Long pagina = InputBox("Introduce el número de la página", "Buscador de páginas") Selection.GoTo wdGoToPage, wd...
  • Jorge5445 

    Use the following code

     

    Dim pagina As Long
    On Error GoTo ErrHndlr
    pagina = InputBox("Introduce el número de la página", "Buscador de páginas", pagina)
    Selection.GoTo wdGoToPage, wdGoToAbsolute, pagina
    ErrHndlr:
    If Err.Number = 13 Then
         MsgBox "You cancelled the process"
         Exit Sub
    End If

     

    The  MsgBox "You cancelled the process" command is optional and can be omitted if you do not want it to appear.

Resources