i currently use a macro that outputs each record of a merged document as a text file, but what we do is add the word "end "
to the last entry in the excel data source
the word macro loops through each record until it sees the word "end" then stops! but with an error ,well that ok but its messy, how can i change it so that once the last record is found it stops!(a message box with "20 generated" or similar would be nice!
here's the code.
Code:Sub Createtext() Do ActiveDocument.MailMerge.DataSource.ActiveRecord = wdNextRecord 'Click the button to select the next record if in manual mode a1 = ActiveDocument.Words(2).Text a2 = ActiveDocument.Words(3).Text a3 = ActiveDocument.Words(4).Text a4 = ActiveDocument.Words(5).Text a5 = ActiveDocument.Words(6).Text a6 = ActiveDocument.Words(7).Text a7 = ActiveDocument.Words(8).Text 'Select the second word of document as reconstructed filename ActiveDocument.SaveAs FileName:=a1 + a2 + a3 + a4 + a5 + a6 + a7 + ".txt", FileFormat:=wdFormatDOSText 'Save the text file Loop Until a1 = "end" ' The last record must contain "end" End Sub
Last edited by martindwilson; 01-09-2010 at 06:11 AM.
Mojito connoisseur and a dabbler in Cisco
where does code go ?
look here
how to insert code
how to enter array formula
why use -- in sumproduct
recommended reading
wiki Mojito
how to say no convincingly
most important thing you need
Martin Wilson: SPV
and RSMBC
i just realise that this code doesnt ever do the first record! i have managed to do all of above and everything now works. if anyone relly wants the code ill put it up but judging by the lack of response hardly anyone seems to use vba in word!
Mojito connoisseur and a dabbler in Cisco
where does code go ?
look here
how to insert code
how to enter array formula
why use -- in sumproduct
recommended reading
wiki Mojito
how to say no convincingly
most important thing you need
Martin Wilson: SPV
and RSMBC
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks