Alaska Software Inc. - Mailmerge with Word
Username: Password:
AuthorTopic: Mailmerge with Word
RIBO SALAMANCAMailmerge with Word
on Tue, 13 May 2014 15:42:38 -0500
Hello community.

I have the following dilemma, I do not save the output file with the data 
replaced.
When you open the output file does not contain the replacements directly, 
only if instructed to do so word.
What is the order for the include file out replacements?

cDbf := 'd:\mailmerge\cartas.dbf'
cProgPath := 'd:\mailmerge\'
oWord := CreateObject("Word.Application")

oWord:visible := .T.

cFileWord:= cProgpath + 'carta.dotx'
oMyDoc := oWord:documents:open( cFileWord )
oMyDoc := oWord:ActiveDocument
oMyDoc:MailMerge:OpenDataSource(CARTAS, .F., .F., .T., .F. )
oMyDoc:MailMerge:Execute(.T.)
cSaveAs := cProgpath + 'cartasdef.doc"
oMyDoc:saveas(cSaveAs)
oMyDoc:close()
oWord:destroy()

Thank you.

Ribo Salamanca.
Peter AlderliestenRe: Mailmerge with Word
on Wed, 14 May 2014 09:07:08 +0200
Ribo, 

> I have the following dilemma, I do not save the output file with the data 
> replaced.
> When you open the output file does not contain the replacements directly, 
> only if instructed to do so word.
> What is the order for the include file out replacements?
> 
> cDbf := 'd:\mailmerge\cartas.dbf'
> cProgPath := 'd:\mailmerge\'
> oWord := CreateObject("Word.Application")
> 
> oWord:visible := .T.
> 
> cFileWord:= cProgpath + 'carta.dotx'
> oMyDoc := oWord:documents:open( cFileWord )
> oMyDoc := oWord:ActiveDocument
> oMyDoc:MailMerge:OpenDataSource(CARTAS, .F., .F., .T., .F. )
> oMyDoc:MailMerge:Execute(.T.)
> cSaveAs := cProgpath + 'cartasdef.doc"
> oMyDoc:saveas(cSaveAs)
> oMyDoc:close()
> oWord:destroy()

I don't know if this ever worked for you, but my (older) documentation says
that :MailMerge returns a readOnly object. Could that still be the cause of
your problem?
If you try and modify the mailMerge Object by inserting some text, does
that deliver a changed document when saved?

Peter
RIBO SALAMANCARe: Mailmerge with Word
on Fri, 16 May 2014 10:55:55 -0500
Thanks Peter, works perfectly as Thomas says.

"Peter Alderliesten" escribió en el mensaje de 
noticias:hiu9ekm0omzb.jim5rwl2oi2g.dlg@40tude.net...

Ribo,

> I have the following dilemma, I do not save the output file with the data
> replaced.
> When you open the output file does not contain the replacements directly,
> only if instructed to do so word.
> What is the order for the include file out replacements?
>
> cDbf := 'd:\mailmerge\cartas.dbf'
> cProgPath := 'd:\mailmerge\'
> oWord := CreateObject("Word.Application")
>
> oWord:visible := .T.
>
> cFileWord:= cProgpath + 'carta.dotx'
> oMyDoc := oWord:documents:open( cFileWord )
> oMyDoc := oWord:ActiveDocument
> oMyDoc:MailMerge:OpenDataSource(CARTAS, .F., .F., .T., .F. )
> oMyDoc:MailMerge:Execute(.T.)
> cSaveAs := cProgpath + 'cartasdef.doc"
> oMyDoc:saveas(cSaveAs)
> oMyDoc:close()
> oWord:destroy()

I don't know if this ever worked for you, but my (older) documentation says
that :MailMerge returns a readOnly object. Could that still be the cause of
your problem?
If you try and modify the mailMerge Object by inserting some text, does
that deliver a changed document when saved?

Peter
Thomas BraunRe: Mailmerge with Word
on Wed, 14 May 2014 11:58:20 +0200
RIBO SALAMANCA wrote:

> cFileWord:= cProgpath + 'carta.dotx'
> oMyDoc := oWord:documents:open( cFileWord )
> oMyDoc := oWord:ActiveDocument
> oMyDoc:MailMerge:OpenDataSource(CARTAS, .F., .F., .T., .F. )
> oMyDoc:MailMerge:Execute(.T.)
> cSaveAs := cProgpath + 'cartasdef.doc"
> oMyDoc:saveas(cSaveAs)

Here, oMyDoc points to the the original mailmerge file, not to the new
document which is a result of the merge process!

Try to insert a "oMyDoc := oWord:ActiveDocument" after the
oMydoc:mailmerge:Execute() line

HTH 
Thomas
RIBO SALAMANCARe: Mailmerge with Word
on Fri, 16 May 2014 10:57:55 -0500
Thanks Thomas, works perfectly
insert a "oMyDoc := oWord:ActiveDocument" after the
oMydoc:mailmerge:Execute() line.

"Thomas Braun" escribió en el mensaje de 
noticias:1jfdwzpg0qm4t$.16b4xd7lnk4my$.dlg@40tude.net...

RIBO SALAMANCA wrote:

> cFileWord:= cProgpath + 'carta.dotx'
> oMyDoc := oWord:documents:open( cFileWord )
> oMyDoc := oWord:ActiveDocument
> oMyDoc:MailMerge:OpenDataSource(CARTAS, .F., .F., .T., .F. )
> oMyDoc:MailMerge:Execute(.T.)
> cSaveAs := cProgpath + 'cartasdef.doc"
> oMyDoc:saveas(cSaveAs)

Here, oMyDoc points to the the original mailmerge file, not to the new
document which is a result of the merge process!

Try to insert a "oMyDoc := oWord:ActiveDocument" after the
oMydoc:mailmerge:Execute() line

HTH
Thomas