End of Document check

J

johnsontw

I am trying to fix some old files (text documents) with Word so I can
then import them into Access as a flat file. I copy a piece of
information at the beginning of the document and then paste it into
the document multiple times (each file is different in length) until I
reach the bottom of the document. Is there any way to check for the
end of the document so I don't have to redo the macro over and over
watching for the end? Like maybe EOF( )? I have been unable to find
anything yet that will work to fully automate my macro.
 
J

Jean-Guy Marcil

(e-mail address removed) was telling us:
(e-mail address removed) nous racontait que :
I am trying to fix some old files (text documents) with Word so I can
then import them into Access as a flat file. I copy a piece of
information at the beginning of the document and then paste it into
the document multiple times (each file is different in length) until I
reach the bottom of the document. Is there any way to check for the

I think you need to explain this part in more details.

As is, I understand that you take a bit of a document and then paste it many
times in the same document... at the end? Aren't you already at the end?
end of the document so I don't have to redo the macro over and over
watching for the end? Like maybe EOF( )? I have been unable to find
anything yet that will work to fully automate my macro.



--

Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 
B

Bear

I think you mean the records are variable in length? And you're pasting some
text at the end of each record?

At any rate, there are three ways to "find the end of a file."

1. Word has some predefined bookmarks that, while hidden, work like any
other bookmark. One is \EndOfDoc.

2. You could put your own EOF marker in the last para and test for that. I
mean just insert a blank para and type [EOF] in it -- or any string you feel
sure will be unique.

3. Rather than process the document from front to back as it's displayed,
you should consider using the Paragraphs collection, and processing each
member of that collection. It would look something like:

Dim objPara as Paragraph

For Each objPara in ActiveDocument.Paragraphs
' do your insertion here
Next objPara

This works through every paragraph in the document, stopping by itself when
it's done the last one.

Bear
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top