Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Mailmerge VFP Database into Word Document
Message
From
23/11/2000 11:45:07
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
ActiveX controls in VFP
Title:
Mailmerge VFP Database into Word Document
Miscellaneous
Thread ID:
00445015
Message ID:
00445015
Views:
69
Hi everyone

I am a new member. I want to mailmerge my VFP table into a Word Document.
Some times I get the 1426 ole error code 0x80020005 Type mismatch while using opendatasource...
It also closes my table "doctable" after I close word..

Thanks
Savita

I am using the following commands, in a pushbutton click event.
**************
Local oWord, lcFileName, lcConnectionString, oFormLetter
select filtfile *** already extracted data records
copy to "C:\iba\tempfile\temp.dbf" all
Thisform.cdatasource="temp"

Thisform.cdatapath="C:\iba\tempfile\"
Thisform.cformletter="c:\huttonml\main\worddoc\"+trim(doctable.doc_fname)+".doc"
***doctable have document file names and description
lcFilename = addbs(Thisform.cDataPath) + Thisform.cDataSource + ".DBF"

lcConnectionString = "DSN=FoxPro Files;UID=;PWD=;SourceDB=" + Thisform.cDataPath + ";SourceType=DBF;Exclusive=No;BackgroundFetch=Yes;Collate=MACHINE;Null=Yes;Deleted=Yes;"

On Error Do DummyErr
oWord = GetObject(,"Word")
ON ERROR DO erhandle WITH ERROR( ), MESSAGE( ), MESSAGE(1), PROGRAM( ), LINENO( )

If Type("oWord") != "O" Then
oWord = CreateObject("Word.Application")
If Type("oWord") !="O" Then
MessageBox("Unable to start MS Word", 0, "Error")
Return
Endif
Endif


With oWord
.visible=.t.
EndWith

lnSelectArea=select()
oWord.Documents.Open(Thisform.cFormLetter, .F., .F., .F., "", "", .F., "", "", 0)
oFormLetter = oWord.ActiveDocument
oWord.ActiveDocument.MailMerge.OpenDataSource(lcFilename, 0, .F., .F., .T., .F., "", "", .F., "", "", lcConnectionString, "", "")

************************
Reply
Map
View

Click here to load this message in the networking platform