PDA

View Full Version : Solved: Copying one document into another (Please help)



ukemike
03-09-2005, 08:33 PM
Hi everyone...

I've been searching for an answer to my problem to the ends of the internet. I hope someone can help me on this forum.

Basically I am doing a program in Access Forms. This program generates a Word document based on the data in the database.

To put it all together, I need to open up a Word document, get it's contents (including formatting), close the document, open a new document and put ('paste') its contents there.

The Word document i am reading from is exactly one page long. After i pasted the document content into the new document i need to do a couple of Find/Replace and then paste another 'copy' of that old document (since the original document is exactly one page long, this second copy will be exactly on page two).
So basically the one document I am reading from it like a template.
And i need to 'copy' this template and 'paste' it into a new document. I would have to keep 'pasting' it for all the records i am reading from the database.

I have accomplished this using Copy/Paste. This works perfect on winXP, but unfortunally the person who i am doing this for uses Win2000. Win2000 cannot do a whole bunch of copy/paste's because the clipboard somehow loses its content and/or its content gets screwed up. Some of kinda of O/S issue. So doing it with copy/paste is out of the question.

I need to find another way of copying that template into my new file X number of times. I heard somewhere that you can do this with the Range object. I tried looking everywhere but could not find any code to this.

I have everything completed except this.
If anyone can help me I would greatly GREATLY appreciate it.

I am using Win2000, Access 2002, Word 2002

Thank you very much
Mike

RobertBC
03-09-2005, 11:36 PM
hey men, if you know how to create macros even through macro recorder you may create a macro. if the task you're doing is daily routine its better to create macro. you have 2 ways to do that. first, through macro recorder. On tools menu select macro and macro recorder, then you will start recording your macro. remember everything you inside the macro recorder will be recorded. and or more advance option you can create your procedure through vba editor.

:friends:

ukemike
03-10-2005, 04:31 AM
Hi,
Thank you for your reply.
I am using VBA editor the whole time. I know about the macros recorder, but i dont know how i can set this range and take this range and put it in another document an X amount of times.
Does anyone know where i go to set the range for a Word document in the Word document (like when i am recording a macro)


THank you
Mike

ukemike
03-10-2005, 08:17 AM
I solved this problem. I was looking around and i found the perfect function.

Selection.InsertFile filenamePath


Thanks
Mike

Anne Troy
03-10-2005, 09:31 AM
Hi, Mike. You can mark your thread as solved using the Thread Tools menu at the top of the thread. :)