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.
Jean-Guy Marcil - 28 Aug 2007 02:34 GMT
johnsontw@comcast.net was telling us:
johnsontw@comcast.net 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.

Signature
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org
Bear - 29 Aug 2007 00:30 GMT
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

Signature
Windows XP, Word 2000