Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VFP to doesn't launch Ms Word's mailmerge 1

Jay9988

Programmer
Mar 2, 2023
51
ID
Hi All,
I have an application to launch MS Word mailmerge.
It is using VFP class: mailmrge.vcx
with this command
Code:
WITH THISFORM._mailmerge
    .cAppTitle = "Kontrak Sewa"    && application name, used in Alerts 
    .nWordProc = 1                    && word processor (1 = Word 6+; 2 = CommaDelim; or user-defined (see below); default = 1)
    .nNewDoc = 2                    && is it a new doc (1 = new, 2 = existing; default = 1)
    .cdocname=mdrive+mfile
    .nTemplate = 1                    && type of main document (Word only, 1 = form letter; 2 = label; 3 = envelope; 4 = catalog; default = 1)
    .cAlias = ALIAS()                && alias of source table or view
    ACOPY(aflds, .aAutoFields)        && fill in array of field names to be used
    .MakeOutput()                    && do the merge
   ENDWITH

But, in several PCs the Word window doesn't launch. In other PCs works fine... The VFP ODBC driver has been installed in all the PCs

Is it anything related to Office version? Because I have 2 PC's, both using Word 2013. The one pc is work fine, and the other pc Word doesn't launch.

Does anyone know the problem ?

Many thanks
 
Is Word actually installed on the machines where you're having a problem? Not the Click to run or Office 365 version?

Tamar
 
Is Word actually installed on the machines where you're having a problem? Not the Click to run or Office 365 version?

Tamar
Hi Tamar,
Yes, the Word is installed, and running. But in several computers, the MS WORD cannot launched from VFP using code above. VFP ODBC Driver is also installed. I have tried in 4 computers: 2 computers is using Word 2016 and 2013, and the code is running properly. The other 2 computers using Word 2013 and 2019, the mailmerge doesn't lounched.
 
Last edited:
Are you sure, so ODBC drivers on both PC are same? Please, compare version and file size.
 
How about bypassing the VFP Mailmerge class and the ODBC driver? In other words, see what happens when you do this:

Code:
loWord = CREATEOBJECT("word.applicaiton")

This will not give you the solution, but it will tell you whether it is Word (or more precisely the Word Automation server) which is at fault, or the VCX or ODBC driver.
 
How about bypassing the VFP Mailmerge class and the ODBC driver? In other words, see what happens when you do this:

Code:
loWord = CREATEOBJECT("word.applicaiton")

This will not give you the solution, but it will tell you whether it is Word (or more precisely the Word Automation server) which is at fault, or the VCX or ODBC driver.
Just pointing out a minor typo in Mike's code that would give you trouble in a cut-and-paste. Should be:

Code:
loWord = CREATEOBJECT("word.application")

Tamar
 
Hi,

what version is the Word app installed? 32 Bit? 64 Bit?

a VFP-App is 32 Bit and can only launch a 32 Bit Word app

Regards, Stefan
 
Hi All, thank you for all your suggestion.

I have tried several things suggested from all of you. The trial is done at the computer that have problem:
- I have uninstalled ODBC Driver, strangely, without ODBC installed, the VFP do not generated any warning when I run the mailmerge code... Then I re-installed the ODBC driver from the source I usually use. The problem is still persist (the Word mailmerge windows cannot launch)
- I tried to run plain Word Application object as @Mike Lewis Suggested. It'is running well. So the problem is in the mailmrge.VCX class?
- I Have checked the Word version, it's 32-bit (as @Stefan suggestion)

Any further suggestion for this problem?
Many thanks all..
 
Looking into the code of the mailmerge class of mailmerge.vcx, it will use the VFP OLEDB Provider with Word 10 or higher. So you should install the VFP OLEDB Provider instead of VFP ODBC driver to get mailmerge going for clients that have Word 10 or higher. And Word 10 is better known as Word 2002 or the Word of Office XP.

It may even be the mechnism to detect the word version from the registry key is getting things wrong, partly because the code doesn't take into account the branches of 32bit vs 64bit registry, partly because the mailmerge.h has strange constants like #DEFINE C_WORD6 "6.0" but also #DEFINE C_WORD6_OR_LATER "6.0" not sure how that would work out.

And for example in string copmparison "10.0"<"6.0", becuase "1"<"6". Though the code uses IF VAL(THIS.cWordVersion) < VAL(C_WORD10), which is fine. But might fail on setting THIS.cWordVersion correctly.

My recommendation would be installing the VFP OLEDB Provider and test with that on a problematic client.
 
Last edited:
Looking into the code of the mailmerge class of mailmerge.vcx, it will use the VFP OLEDB Provider with Word 10 or higher. So you should install the VFP OLEDB Provider instead of VFP ODBC driver to get mailmerge going for clients that have Word 10 or higher. And Word 10 is better known as Word 2002 or the Word of Office XP.

It may even be the mechnism to detect the word version from the registry key is getting things wrong, partly because the code doesn't take into account the branches of 32bit vs 64bit registry, partly because the mailmerge.h has strange constants like #DEFINE C_WORD6 "6.0" but also #DEFINE C_WORD6_OR_LATER "6.0" not sure how that would work out.

And for example in string copmparison "10.0"<"6.0", becuase "1"<"6". Though the code uses IF VAL(THIS.cWordVersion) < VAL(C_WORD10), which is fine. But might fail on setting THIS.cWordVersion correctly.

My recommendation would be installing the VFP OLEDB Provider and test with that on a problematic client.
Hi Chriss,

Yes, your suggestion to install VFP Oledb is working
Thanks a lot
 

Part and Inventory Search

Sponsor

Back
Top