VBA // Word For .. Next & stop at EOF - Programmers Heaven

Howdy, Stranger!

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

Categories

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.