Losing content of Field after merge to new Document

J

jasper.nijkamp

Hi Guys (and Girls)

i wrote a macro that merges a document to a new one, but the problem
is that the date n subject disappear after the merge (in the new
document).
does anyone now how i can solve that?
My mergecode is:

With ActiveDocument
If .ProtectionType <> wdNoProtection Then .Unprotect
Password:=""
If ActiveDocument.MailMerge.State = wdMainAndDataSource Then
ActiveDocument.MailMerge.Execute

.Protect Type:=wdAllowOnlyFormFields, NoReset:=True,
Password:=""

Thanks in advance

Jasper
 
J

John McGhie

Hi Jasper:

A document can have only one set of "Properties". When you merge a document
into another document, the "outer" set of properties persists: the
properties of the merge destination document will not be overwritten.

So you will need to retrieve and store the properties from your source
document before the merge, then merge, then update the active document's
properties following the merge.

Subject is simple: Date is much more difficult, because that will be
re-written by the operating system when the document is closed. Preventing
that requires some serious coding.

I suggest that you move the date into a different property, preferably a
Custom Document Property that you create for the purpose.

Cheers


Hi Guys (and Girls)

i wrote a macro that merges a document to a new one, but the problem
is that the date n subject disappear after the merge (in the new
document).
does anyone now how i can solve that?
My mergecode is:

With ActiveDocument
If .ProtectionType <> wdNoProtection Then .Unprotect
Password:=""
If ActiveDocument.MailMerge.State = wdMainAndDataSource Then
ActiveDocument.MailMerge.Execute

.Protect Type:=wdAllowOnlyFormFields, NoReset:=True,
Password:=""

Thanks in advance

Jasper

--
Don't wait for your answer, click here: http://www.word.mvps.org/

Please reply in the group. Please do NOT email me unless I ask you to.

John McGhie, Consultant Technical Writer
McGhie Information Engineering Pty Ltd
http://jgmcghie.fastmail.com.au/
Sydney, Australia. S33°53'34.20 E151°14'54.50
+61 4 1209 1410, mailto:[email protected]
 

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