![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
New Member
Join Date: Apr 2002
Location: Atlanta, GA
Posts: 4
|
I have a mail merge document in Word that is pulling data from an Excel worksheet for about 200 unique items. Thru the merge I am trying to create a new document (in Word), save as a new name and move down the records in Excel to create and save as the next record. I would like to do this for each individual record (create & save).
My trouble is that the mail merge creates one big file and saves it as a single file. I have code that I am trying to make work (somehow) to get it to see the individual id's in the excel range that I am merging but I am stuck. If anyone is familiar with mail merging to create individually saved documents from the master merge record, preferrably with the individual record number as the saved filename, PLEASE let me know. The code I'm working with is as follows: Sub SavePart2() Dim sName As String Dim sFirstPart As String Dim sSecondPart As String sFirstPart "D:filename" Dim I As Integer Documents.Open FileName:="path", ConfirmConversions:= _ False, ReadOnly:=False, AddToRecentFiles:=False, PasswordDocument:="", _ PasswordTemplate:="", Revert:=False, WritePasswordDocument:="", _ WritePasswordTemplate:="", Format:=wdOpenFormatAuto With ActiveDocument.MailMerge .Destination = wdSendToNewDocument .MailAsAttachment = False .MailAddressFieldName = "" .MailSubject = "" .SuppressBlankLines = True With .DataSource For I = 1 To wdDefaultLastRecord .FirstRecord = I .LastRecord = I sSecondPart = .DataFields.Count(0).Value & "03" sName=sFirstPart & sSecondPart ActiveDocument.SaveAs FileName:=sName, FileFormat:= _ wdFormatDocument, LockComments:=False, Password:="", AddToRecentFiles:= _ True, WritePassword:="", ReadOnlyRecommended:=False, EmbedTrueTypeFonts:= _ False, SaveNativePictureFormat:=False, SaveFormsData:=False, _ SaveAsAOCELetter:=False .Execute Pause:=True End With End With Next End Sub -KB |
|
|
|
|
|
#2 |
|
Board Regular
Join Date: Feb 2002
Posts: 3,065
|
Hi
i would not merge in word, im becomming frieds wit hword i have used this week but would suggest vba casse times different senerios and have ss to these templates cells kink whats th efiked in word and save on the trim.. this wil allow table array to excel/merge and save on te fly each SS eaqch doc, which is what yoy want... if you understand that post you be able to do thai alone else let me know ill post my code and advise to do this. funny ive offered this b4 no one seems to lie excel doing merges.. amy reason?
__________________
Free Excel based Web Toolbar available here. Jack in the UK J & R Excel Solutions "making Excel work for you" |
|
|
|
|
|
#3 |
|
New Member
Join Date: Apr 2002
Location: Atlanta, GA
Posts: 4
|
If you would be able to post the code you have for this, that would be wonderful. Thank you!!!
|
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|