Home |
Search |
Today's Posts |
|
#1
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Word Merge - All At One
in the file, but still the document's not conected to the source
You may need to follow the instructions he http://support.microsoft.com/kb/825765/en-us ask me to select table (excel sheet's - i changed the suffix code of the place of the source to .xls ) for every word document that i have For .xls sources try replacing ..OpenDataSource DataFile with this ' you can put these at the top of your macro if you prefer Dim strSheetName As String strSheetName = "Sheet4" ..OpenDataSource _ Name:=DataFile, _ SQLStatement:="SELECT * FROM [" & strSheetName & "$]" -- Peter Jamieson http://tips.pjmsn.me.uk "יריב החביב" wrote in message ... thank you I think i get closer, now another dialog box open and ask me to select table (excel sheet's - i changed the suffix code of the place of the source to .xls ) for every word document that i have in the file, but still the document's not conected to the source -- תודה רבה "Peter Jamieson" wrote: You could try making a couple of changes to Graham's suggested code, something like the following. This updates the mail merge data source for each file, then performs the merge immediately. Dim fDialog As FileDialog Dim DataFile As String ' I prefer to store a reference to the documents the code is working with Dim oDoc As Word.Document DataFile = "D:\My Documents\Test\Names Data.doc" Set fDialog = Application.FileDialog(msoFileDialogFolderPicker) With fDialog .Title = "Select Folder containing the letters and click OK" .AllowMultiSelect = False .InitialView = msoFileDialogViewList If .Show -1 Then MsgBox "Cancelled By User" Exit Sub End If DocDir = .SelectedItems.Item(1) If Right(DocDir, 1) "\" Then DocDir = DocDir + "\" End With On Error Resume Next If Documents.Count 0 Then Documents.Close SaveChanges:=wdPromptToSaveChanges End If ' All the changes are in this part DocList = Dir$(DocDir & "*.doc") Do While DocList "" Set oDoc = Documents.Open(DocList) With oDoc.MailMerge .MainDocumentType = wdFormLetters .OpenDataSource DataFile .Destination = wdSendToPrinter With .DataSource .FirstRecord = wdDefaultFirstRecord .LastRecord = wdDefaultLastRecord End With End With ' If you don't actually need to save the new data source do this oDoc.Close wdDoNotSaveChanges ' But if you might need to re-run the merge agains thte data source you are currently using, do this ' oDoc.Close wdSaveChanges Set oDoc = Nothing DocList = Dir$() Loop -- Peter Jamieson http://tips.pjmsn.me.uk "יריב החביב" wrote in message ... thank you, it is geting closer but i still have not reach the target. the dialog box open and i can select the folder but i dont see the files (letters) i choose the folder (without seeing the files) and it run, but finaly the letters not conected to the data source) -- תודה רבה "Graham Mayor" wrote: The following macro will attach the same data source - here "D:\My Documents\Test\Names Data.doc" to all the files in a folder selected from the dialog. Dim fDialog As FileDialog Dim DataFile As String DataFile = "D:\My Documents\Test\Names Data.doc" Set fDialog = Application.FileDialog(msoFileDialogFolderPicker) With fDialog .Title = "Select Folder containing the letters and click OK" .AllowMultiSelect = False .InitialView = msoFileDialogViewList If .Show -1 Then MsgBox "Cancelled By User" Exit Sub End If DocDir = .SelectedItems.Item(1) If Right(DocDir, 1) "\" Then DocDir = DocDir + "\" End With On Error Resume Next If Documents.Count 0 Then Documents.Close SaveChanges:=wdPromptToSaveChanges End If DocList = Dir$(DocDir & "*.doc") Do While DocList "" Documents.Open DocList With ActiveDocument.MailMerge .MainDocumentType = wdFormLetters .OpenDataSource DataFile End With Documents.Close wdSaveChanges DocList = Dir$() Loop -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org ???? ????? wrote: Yes, i have 30 standard letter's and i want them as they are (30 standard . . .) but i want them to use the same datasource, and i want to save time by choose this datasource for all of them in one action, instead of each letter seperately. THANK YOU ???? ??? "Graham Mayor" wrote: Now it is my turn not to understand The principle of mail merge is that you create a standard letter with the text common to all and attach the data source to insert the variable information from that data source. Thus if there are thirty records in your data source you will get thirty letters. -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org ???? ????? wrote: thank you Graham, But it is still not answer my question (or that i don't understand ...) Is there a way to "Choose the data source" (one datasource) for 30 letter's in one action (instead of choosing the datasource seperately for each letter) ??? thank you That's what mailmerge does? See http://www.gmayor.com/mail_merge_lab...th_word_xp.htm or http://www.gmayor.com/merge_labels_with_word_2007.htm If you want to end up with a separate document for each record, see also http://www.gmayor.com/individual_merge_letters.htm -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org ???? ????? wrote: Hello, We have to merge 30 letters to one data source . The letters are separate entity. Is there any way to do it in one action insted of every letter seperately ? if the answer is Yes, please tell me how. thank you |
Reply |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Word 2003 pulls up my mail merge template, but doesn't complete the merge into a new Form Letter 1 | Mailmerge | |||
Problem with merge data to word document merge field | Microsoft Word Help | |||
How to merge Excel chart for mass Word Mail Merge for employees | Mailmerge | |||
Maniplulating the data source location of a merge, MS Word merge | Mailmerge | |||
Insert Merge Field problem with Word-Mail Merge from Excel documen | Microsoft Word Help |