General information
Category:
ActiveX controls in VFP
Title:
Mailmerge VFP Database into Word Document
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
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only