Changing name of document merged

J

Janfry

Hi.

Using Word2003, I do a mailmerge to a new Document,
ActiveDocument.MailMerge.Destination = wdSendToNewDocument
The property ActiveDocumentName is read-only, and I want to change the name
of the document generated by Word (Letter1.doc) without using SaveAs or, if
not possible, is there any way to change the name of document that Word
autogenerates?.

Best Regards,

Janfry
 
D

Doug Robbins - Word MVP

Take a look at the code in the add-in that you can download from:

http://www.gmayor.com/individual_merge_letters.htm

With a modification of that code, you could do what you want.


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 
G

Graham Mayor

A document doesn't have a name until you save it? Letters(n) is just a
working title and not editable.

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
P

Peter Jamieson

If you are trying to change the title that the User sees, try changing the
output document's .ActiveWindow.Caption property

(typically, immediately post-merge, the new document is the ActiveDocument
unless you have also produced an Error document)

However, I think you will need to ensure that the caption is unique , in
much the same way as Word does when it appends a sequence number.

If you are trying to change the default name that Word will try to use when
the user saves the document, try setting the output document's Title
property to the name you want.

However, you cannot just set

..BuiltInDocumentProperties("Title")

because Word seems to throw away the value you assigned to the title (I
think this is to do with the way that, by default, Word uses the first word
or so in the document as the default file name). But it seems to work OK if
you Exccute the dialog.

e.g. something like

Sub SetCaptionAndTitle()
Dim dlgFSI As Word.Dialog

' assume the ActiveDocument is the OutputDocument
ActiveDocument.ActiveWindow.Caption = "the caption you want"

Set dlgFSI = ActiveDocument.Application.Dialogs(wdDialogFileSummaryInfo)
With dlgFSI
.Title = "the file name you want"
.Execute
End With
Set dlgFSI = Nothing
End Sub

Peter Jamieson
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top