Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

VBA // Word For .. Next & stop at EOF

campocampo Posts: 2Member
I am using vb to remove certain paragraph symbols throughout a word document. I want it to stop after the first pass through the document but, I can't get the For..Next to exit at EOF. Any suggestions?

Comments

  • DarQDarQ Posts: 1,625Member
    : I am using vb to remove certain paragraph symbols throughout a word document. I want it to stop after the first pass through the document but, I can't get the For..Next to exit at EOF. Any suggestions?
    :

    You can exit a for/next loop by using the EXIT FOR statement. It's even better if you use a do while loop for example.

    dim intFile as integer

    intfile = freefile
    open "filename.ext" for input as #intFile
    do while not eof(intFile)
    ' some code!!!
    Loop
    Close #intFile

    Doegjes!


  • campocampo Posts: 2Member
    : : I am using vb to remove certain paragraph symbols throughout a word document. I want it to stop after the first pass through the document but, I can't get the For..Next to exit at EOF. Any suggestions?
    : :
    :
    : You can exit a for/next loop by using the EXIT FOR statement. It's even better if you use a do while loop for example.
    :
    : dim intFile as integer
    :
    : intfile = freefile
    : open "filename.ext" for input as #intFile
    : do while not eof(intFile)
    : ' some code!!!
    : Loop
    : Close #intFile
    :
    : Doegjes!
    :
    :
    :

    Thanks, IT works...

    Campo

Sign In or Register to comment.