Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / March 2005

Tip: Looking for answers? Try searching our database.

Mailmerge create a file for each section...

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
nad1 - 03 Mar 2005 17:01 GMT
Hi i have some probleme with this script...

http://support.microsoft.com/kb/306348/en-us

Sub BreakOnSection()
   ' Used to set criteria for moving through the document by section.
   Application.Browser.Target = wdBrowseSection

   'A mail merge document ends with a section break next page.
   'Subtracting one from the section count stop error message.
   For i = 1 To ((ActiveDocument.Sections.Count) - 1)

'Note: If a document does not end with a section break,
'substitute the following line of code for the one above:
'For I = 1 To ActiveDocument.Sections.Count

      'Select and copy the section text to the clipboard.
      ActiveDocument.Bookmarks("\Section").Range.Copy

      'Create a new document to paste text from clipboard.
      Documents.Add
      Selection.Paste

   ' Removes the break that is copied at the end of the section, if any.
      Selection.MoveUp Unit:=wdLine, Count:=1, Extend:=wdExtend
      Selection.Delete Unit:=wdCharacter, Count:=1
ChangeFileOpenDirectory "C:\"
      DocNum = DocNum + 1
     ActiveDocument.SaveAs FileName:="test_" & DocNum & ".doc"
     ActiveDocument.Close
      ' Move the selection to the next section in the document.
     Application.Browser.Next
   Next i
   ActiveDocument.Close savechanges:=wdDoNotSaveChanges
End Sub

It's execute normaly but no file is created...

An idea ? Thanks.
John - 10 Mar 2005 22:09 GMT
I was able to run this script, and it did create the output files.  I was
actually looking for code like this for my project.  Thanks for posting it.
Let me know if you can't get it working.  How about saving to a different
directory?  Do you have write access to "c:\"?

jc

> Hi i have some probleme with this script...
>
[quoted text clipped - 35 lines]
>
> An idea ? Thanks.

Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.