merge sections of multiple word docs by running a macro from excel

L

lieven

Hello,

I want to run a macro from excell that copys sections of different word
documents into a new one.
I would build each doc like this:

[DUTCH]

Dit is de Nederlandse tekst voor een LOOPGANG

[END]



[GERMAN]

Das ist der Deutsche tekst für ein LAUFSTEG

[END]



[ENGLISH]

This is the English text for a WALKWAY

[END]



[FRENCH]

Voici le texte francais pour une PASSERELLE

[END]

Depending on the language selected in excel I would like the section
corresponding with it to be copied into a new doc.

Eg. if the language is set to english I wan the text [ENGLISH] and the next
[END] being "This is the English text for a WALKWAY" to be copy into a new
doc.

I already got the code to copy entire docs but i would like to alter it to
perform the actions as described above.

Sub MergeWordDocs()

Dim wrdApp As Object, strFile As String
Dim wrdDoc As Object, wrdNew As Object
Set wrdApp = CreateObject("Word.Application")
Set wrdNew = wrdApp.Documents.Add

strFiles = "c:\1.doc,c:\2.doc,c:\Quick Response SLA.doc"

For intTemp = 0 To UBound(Split(strFiles, ","))
Set wrdDoc = wrdApp.Documents.Open(Split(strFiles, _
",")(intTemp), ReadOnly:=True)
wrdDoc.Range.Copy
Set myRange = wrdNew.Range(wrdNew.Content.End - 1, _
wrdNew.Content.End - 1)
myRange.Paste
wrdDoc.Close False: Set wrdDoc = Nothing
Next

wrdNew.SaveAs "c:\merge1.doc": wrdNew.Close True
wrdApp.Quit: Set wrdApp = Nothing

End Sub


Thanks,



Lieven
 
K

ker_01

Lieven:

(1) Please change your system date to the correct date before making any
more posts. By creating a a post with a date in the future, your post remains
out of order for everyone else using this newsgroup.

(2) Although your code may ultimately reside in Excel, your core question
seems to be about the Word object model (how to find and select certain
ranges within a Word document). You are more likely to get a timely and
complete response in the Word.Programming newsgroup; then you can adapt those
answers back into Excel VBA accessing the Word object model.

Best,
Keith
 
Top