Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default merge sections of multiple word docs by running a macro from excel

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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 395
Default merge sections of multiple word docs by running a macro from excel

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

"lieven" wrote:

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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Trying to pull data from multiple sheets (and Word docs too) ShaunRichard Excel Discussion (Misc queries) 1 January 24th 08 09:02 PM
Import cells from excel into word and create multiple word docs scdaddy7269 Excel Programming 2 March 20th 06 07:03 PM
Code in Excel macro to get all open Word docs? Ed Excel Programming 4 February 8th 06 04:04 PM
Embedding Word Docs into Excel Worksheets and Then Printing The Word Docs mr_melvis Excel Worksheet Functions 1 April 8th 05 03:00 AM
converting excel docs to word docs rolercster New Users to Excel 2 January 4th 05 07:11 PM


All times are GMT +1. The time now is 05:14 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"