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
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