Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Hiding datasource dialog in MS Word MailMerge
Message
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Miscellaneous
Thread ID:
00899134
Message ID:
00901439
Views:
15
Hi Rod,
Can you help me on this Mail Merge? What I'm doing is I'm working on the MailMerge Wizard of VFP7, There's a note that if MS Word 10 or higher, need to use an OLEDB Provider like this...
I modified already to point to my DBC.
cODBCSource = [Provider=VFPOLEDB.1;Data Source=c:\crm\data\crmvfp.dbc], but when I used this, I got different error, # 1426 = OLE error code 0x"name"

The code below is the original one..

PRIVATE colddocs, wa
LOCAL cDummy, nWordDocType, cSqlStmt, cODBCSource, cDBQPath
LOCAL oDoc

*- We need to set the Localization ID to english (1033)
*- so that OLE Automation will be understood by OLE server.
=SYS(3006,I_ENGLISH)

WAIT WINDOW C_STARTWORD80_LOC NOWAIT
*- create word object
wa = CreateObject(WIN_8OBJ)

*- Check if problem creating Word object
IF TYPE('wa') # 'O'
THIS.ALERT(E_NOOPENWORD_LOC)
RETURN
ENDIF

*- Test language
THIS.lEnglish = (wa.application.international[26] == I_ENGLISH)

*- Get data -- should use same directory as foxpro table
SELECT (THIS.cAlias)
*/* Original Code
m.cDBQPath = IIF(EMPTY(THIS.cDataPath),SYS(2027,SET("DEFA") + SYS(2003)),THIS.cDataPath)

IF THIS.lHas30Drivers
cODBCSource = "DSN="+THIS.cODBC_DSN+;
";SourceDB="+IIF(EMPTY(THIS.cDBCName),m.cDBQPath,THIS.cDBCName)+;
";SourceType="+IIF(EMPTY(THIS.cDBCName),"DBF","DBC")+;
";Exclusive=No"+;
";BackgroundFetch=Yes;"
ELSE
cODBCSource = "DSN=" + THIS.cODBC_DSN + ;
";DBQ=" + m.cDBQPath + ;
";DefaultDir=" + m.cDBQPath + ;
";FIL=" + THIS.cODBC_FIL +";"
ENDIF

*-
*-

*- cODBCSource = "File name=d:\vfp.bug\test1.udl"
*- cODBCSource = [Provider=VFPOLEDB.1;Data Source=d:\vfp.bug\foo.dbc]

IF THIS.nNewDoc = N_EXISTING_DOC
oDoc = wa.documents.Open(THIS.cDocName)
ELSE
oDoc = wa.documents.Add
*- set main document type
DO CASE
CASE THIS.nTemplate = N_LABEL
m.nWordDocType = 1
CASE THIS.nTemplate = N_ENVELOPE
m.nWordDocType = 2
CASE THIS.nTemplate = N_CATALOG
m.nWordDocType = 3
OTHERWISE
m.nWordDocType = 0
ENDCASE
oDoc.MailMerge.MainDocumentType = m.nWordDocType
ENDIF

WAIT WINDOW C_OPENDATA80_LOC NOWAIT

*- attach data file
oDoc.MailMerge.OpenDataSource(THIS.cDataSrc,0,0,0,0,0,"","",0,"","",m.cODBCSource,;
THIS.csqlstmt, THIS.csqlstmt2)

WAIT CLEAR

*- activate MSW with proper document
wa.Visible = .T.
wa.Activate

IF THIS.nNewDoc = N_NEW_DOC
*- display Word MailMergeHelper dialog
IF THIS.nTemplate # N_FORMLETTER
wa.Dialogs[I_WDDIALOGMAILMERGEHELPER].Show
ENDIF
ENDIF

*- terminate the connection
wa = .NULL.

RETURN
Im opening a Table from a dbc, most sample I see here are in excel format.

Any thing to make this work? This is the VFP Mailmerge Wizard Code... I thinking of asking to fellows than doing a trial and error which is time consuming..

Thanks in advance..


Jojo R. dela Cuesta
Dalplus Technologies
http://www.dalplus.com
Jojo R. dela Cuesta, B.Sc.
eConsultant, Programmer
Dalplus Technologies
http://www.dalplus.com
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform