Re: Word Automation in VB6
Well, at the moment you are using the .ActiveDocuemnt property to get the current doc. I would firstly store that in a variable. Secondly, get any other docs using the . Docuements property.
Re: Word Automation in VB6
I am not understanding you when you say store that in a variable. I am not sure I know what or how to store it. Do you mean capture the contents of objWD.activedocument.Bookmarks.Item("Actions").Range.Text and assign it to a variable?
I am not worried about the other documents, I have them already. I just want to see if I can copy what's on this document to the other's using the application.
Thanks
Kim
Re: Word Automation in VB6
I think Pinky98 had something like this in mind:
Code:
Dim oDoc As Word.Document
i = rs.RecordCount
Do While i > 0
Set oDoc = objWD.ActiveDocument
oDoc.Bookmarks.Item("Actions").Range.Text = frmAircraftWO.rtxtActions & vbCrLf
'....
Make an object variable for a document, and then assign the ActiveDocument reference to it. That way, you can make different documents active and still keep track of which document you are working on. After that, pretty much all you have to do is assign the other documents to objects, and then work on all of them at once. Something like:
Code:
Dim oDoc2 As Word.Document, oDoc3 As Word.Document, oDoc4 As Word.Document
Set oDoc2 = objWD.Documents.Open("File1.doc")
Set oDoc3 = objWD.Documents.Open("File2.doc")
Set oDoc4 = objWD.Documents.Open("File3.doc")
'Now you can work with all of the documents at once.
oDoc2.Bookmarks.Item("Actions").Range.Text = oDoc.Bookmarks.Item("Actions").Range.Text
'Etc.
Re: Word Automation in VB6
Oh, I see what you mean. I have done that already but I did it seperately for each document. I guess if I set all the documents together in one command than all of the text will be copied to each documenta at the same time. I think I have got it. Sometimes figuring out the layout of how your code should be is not easy, nor does it make sense at first. My thought at that point in time is to get it to work, not how to get it to work efficiently.
Thanks Comintern.