OK. To try each of these macros in Word 2010 (which, sorry, I didn't specify previously), I opened one of these *.txt docs and pasted its contents into an empty Word doc. Then I ran these macros, with the following results:
(1) Re: the SplitDocument macro (macropod):
"Run-time error '4605': This method or property is not available because no text is selected."
Debug button highlights the ".Copy" line (With DocSrc > With .Range > With Rng).
I guess there must be a Select command that I could insert somewhere before that?
(2) Re: the SplitDoc macro (gmayor):
It asked me for a filename. I thought it was offering to save the pasted text as a Word doc, in whole or in part. I offered Doc001. It said, "Run-time error '5152': This is not a valid file name." So then I figured it was asking for the name of an input file. I closed the opened Word doc, ran the macro again, and specified the input .txt file. But then it said, "Run-time error '4248': This command is not available because no document is open." Debug highlighted "Set oDoc = ActiveDocument."
I tried again with an open but empty Word doc. It offered the Save As dialog. I entered Doc001.docx. It repeated the 5152 error. This time, Debug highlighted "oDoc.SaveAs2 strDocName."
For both of these macros:
Once I figure this out, I'll probably comment the macro to clarify the proper opening steps for a complete noob, so I'll be able to use the macro in the future without stumbling around like this.
Thank you, both of you, for going to the trouble of working up that code. I have a hard time learning coding unless I put in a lot of time. I did that for batch, back in the day, and also for WordPerfect scripts, which made great sense to me. But for some reason I've had a learning block when it comes to VBA. It always seems like I'd have to devote several months to it, and I can't.
|