V
Van123
Hi All
I hope someone can help me with a problem, that has been driving me
mad !!
I created a macro, which spits a mail merge file, into separate
pages...ie if there were 24 pages in the mail merge document, the
macro will split the document into 24 separate docs, and save them to
a folder. Until now, I have not been concerned about the names
assigned to the files, and so used the line of code:
ActiveDocument.SaveAs FileName:="course details_" & DocNum & ".doc"
Now however, I wish to assign a name to the newly separated file with
info from one of the fields from the datasource, so that each filename
is specific to info contained in it. I would like the name of the
file to be the employee no e.g 1048.doc.
I have not created a macro to perform the mail merge itself, perhaps i
need this ??
This is the code so far ....just to split the mailmerge doc .....
Sub BreakOnPage()
' Used to set criteria for moving through the document by page.
Application.Browser.Target = wdBrowsePage
For i = 1 To ActiveDocument.BuiltInDocumentProperties("Number of
Pages")
'Select and copy the text to the clipboard.
ActiveDocument.Bookmarks("\page").Range.Copy
' Open new document to paste the content of the clipboard into.
Documents.Add
Selection.Paste
Selection.TypeBackspace
ChangeFileOpenDirectory "C:\Training"
DocNum = DocNum + 1
ActiveDocument.SaveAs FileName:="course details_" & DocNum &
".doc"
ActiveDocument.Close
' Move the selection to the next page in the document.
Application.Browser.Next
Next i
ActiveDocument.Close savechanges:=wdDoNotSaveChanges
End Sub
Please someone help me !!!!!!
I hope someone can help me with a problem, that has been driving me
mad !!
I created a macro, which spits a mail merge file, into separate
pages...ie if there were 24 pages in the mail merge document, the
macro will split the document into 24 separate docs, and save them to
a folder. Until now, I have not been concerned about the names
assigned to the files, and so used the line of code:
ActiveDocument.SaveAs FileName:="course details_" & DocNum & ".doc"
Now however, I wish to assign a name to the newly separated file with
info from one of the fields from the datasource, so that each filename
is specific to info contained in it. I would like the name of the
file to be the employee no e.g 1048.doc.
I have not created a macro to perform the mail merge itself, perhaps i
need this ??
This is the code so far ....just to split the mailmerge doc .....
Sub BreakOnPage()
' Used to set criteria for moving through the document by page.
Application.Browser.Target = wdBrowsePage
For i = 1 To ActiveDocument.BuiltInDocumentProperties("Number of
Pages")
'Select and copy the text to the clipboard.
ActiveDocument.Bookmarks("\page").Range.Copy
' Open new document to paste the content of the clipboard into.
Documents.Add
Selection.Paste
Selection.TypeBackspace
ChangeFileOpenDirectory "C:\Training"
DocNum = DocNum + 1
ActiveDocument.SaveAs FileName:="course details_" & DocNum &
".doc"
ActiveDocument.Close
' Move the selection to the next page in the document.
Application.Browser.Next
Next i
ActiveDocument.Close savechanges:=wdDoNotSaveChanges
End Sub
Please someone help me !!!!!!