none
Is there a way of adding line numbers or other labels to the VBA Word Visual Basic display and then program a GOTO or equivelant to jump to that line of code? RRS feed

  • Question

  • Is there a way of adding line numbers or other labels to the VBA Word Visual Basic display and then program a GOTO or equivalent to jump to that line of code?

    I am working on a Word Macro where the logic is very complex and does not lend itself to an If-Than-Else structure.  So I want to have numerous places in the code where if conditions are met, the program jumps to a particular line or block of code.


    Lewis D. Eigen


    • Edited by LDEigen Monday, April 23, 2018 4:48 PM
    Monday, April 23, 2018 4:44 PM

Answers

  • The code in that thread is not specific to Access, it can be used in any Office application.

    Once lines are numbered, you can use a statement such as

    GoTo 37

    to jump to line 37.


    Regards, Hans Vogelaar (http://www.eileenslounge.com)

    • Marked as answer by LDEigen Monday, April 23, 2018 9:48 PM
    Monday, April 23, 2018 9:26 PM

All replies

  • Monday, April 23, 2018 6:35 PM
  • Thank you <g class="gr_ gr_72 gr-alert gr_gramm gr_inline_cards gr_run_anim Punctuation only-ins replaceWithoutSep" data-gr-id="72" id="72">Hans</g>.

    I looked through the Stack Overflow material and I do not quite see its relevance to my problem.  I am creating a Macro for Word and the material is coded for Access and I am not sure how to change it.  Moreover, the purpose of my numbering the lines of code is to be able to branch to particular lines in the coding itself.  I can see no reference to how to address (GOTO) a line that has been numbered.  Is there something I am missing there?


    Lewis D. Eigen






    • Edited by LDEigen Monday, April 23, 2018 8:33 PM
    Monday, April 23, 2018 8:26 PM
  • The code in that thread is not specific to Access, it can be used in any Office application.

    Once lines are numbered, you can use a statement such as

    GoTo 37

    to jump to line 37.


    Regards, Hans Vogelaar (http://www.eileenslounge.com)

    • Marked as answer by LDEigen Monday, April 23, 2018 9:48 PM
    Monday, April 23, 2018 9:26 PM
  • Thanks, then I will give it a try.  I appreciate the suggestion.

    Lewis D. Eigen

    Monday, April 23, 2018 9:49 PM