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
 
D

Doug Robbins - Word MVP

The reason that no-one has yet responded to your original post is probably
that none of us really understand what you want to do, which is compounded
by the fact that the code that you posted does not seem to address the issue
at all.

Where is the language being set? If you want to create a Word document, why
are you starting from Excel?

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
 
T

That Guy

As has been noted I am not sure what you are asking for help with, a
little more background would be helpful.

That being said; if I had a number of text sections that I needed to
add to a word document I would use word and a user form to do it.

Have the form open when the document opens and on the form you could
have as little as a drop down menu that has your language selection in
it, then when someone selects the language you could easily drop the
required text into the document's range.

I am going to go ahead and assume that you have some kind of spread
sheet that is creating compiled documents from a number of documents
that contain predefined script elements.

If this is true I would ask why are you using excel? You can design
very robust vba forms behind word documents that can do everything an
excel spread sheet can. If it is because you need to work with a range
of Name Language pairs so that you can create individual documents for
a group of people that have a bunch of different languages, then again
I would use word and read the data out of the Excel using a jet
interface and treating it as a database.

I have always been told there is more than one way to skin a cat, and
I have learned that it is exceptionally applicable in the computer
science universe.

Let us know some more about what your doing and we can probably help
you find a solution.
 
Top