Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
OLE Automation with Word Perfect
Message
De
17/08/1998 06:58:13
 
 
À
17/08/1998 01:26:35
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00113342
Message ID:
00127334
Vues:
28
>Hi Marcia -
>
>I was looking for some info about doing merges with WP and you seem to be one of a few who are doing this. I see that you were asking about OLE Automation as opposed to using DDE. I know next to nothing about either. Can you tell me why you wanted to use one over the other (i.e. advantages/disadvantages) and where you went to go to get started? I'm just not quite sure how to use either to accomplish what I want to do (namely, call WP from within VFP to do mail merges).
>
>Thanks,
>
>Sylvia
Hi Sylvia.

I have never been able to use OLE automation successfully with Word Perfect. So I am sticking with DDE. Also, my application is a sales force automation tool. The salesmen buy their own software, so my app also must work with Word Perfect version 6.1. That version does not support OLE automation. All you need to do to figure out the DDE command is to record a macro to do what you need to do and then edit that macro. All the commands are there. In the meantime, here is my code for doing the mailmerge to get you started:
IF ALLTRIM(THISFORM.cWordPerfectVersion) = "8"
	lcCmd = "Application (WordPerfect; "+CHR(34)+"WordPerfect"+CHR(34)+"; Default!;" + ;
		CHR(34) + "EN" + CHR(34) + ")"
ELSE
	lcCmd = "Application (WordPerfect; "+CHR(34)+"WordPerfect"+CHR(34)+"; Default; " + ;
		CHR(34) + "US" +CHR(34) + ")"
ENDIF
DDEEXECUTE(lnDDEChan, lcCmd)
IF ALLTRIM(THISFORM.cWordPerfectVersion) <> "8"
	DDEEXECUTE(lnDDEChan, "ViewDraft ()")
ENDIF

* set the import file name
lcCmd = "ImportSetFileName (Filename: " + CHR(34) + lcImportFile + CHR(34) + ")"
DDEEXECUTE(lnDDEChan, lcCmd)

* run the macro to create the appropriate .DAT file
lcCmd = "MacroFilePlay (Filename: " + CHR(34) + lcMacroName + CHR(34) + ")"
DDEEXECUTE(lnDDEChan, lcCmd)
=INKEY(THISFORM.nMacroDelay)
IF ALLTRIM(THISFORM.cWordPerfectVersion) = "8"
	lcCmd = "FileSave (Filename: " + CHR(34) + lcDataFile + CHR(34) + ;
		"; ExportType: WordPerfect_6_7_8!)"
ELSE
	lcCmd = "FileSave (Filename: " + CHR(34) + lcDataFile + CHR(34) + ;
		"; ExportType: WordPerfect_60!)"
ENDIF
* Since we erased the datafile at the beginning of this routine, just send the save command
* until the file exists. 
* save the imported .DAT file
DO WHILE !FILE(lcDataFile)
	DDEEXECUTE(lnDDEChan, lcCmd)
    =INKEY(THISFORM.nFileSaveDelay)		&& give it a chance to save the file
ENDDO	
DDEEXECUTE(lnDDEChan, "Close (Save: No!)")		&& close the open file
=INKEY(.2)
DO WHILE DDELastError() <> 0
   DDEEXECUTE(lnDDEChan, "Close (Save: No!)")		
   =INKEY(.2)
ENDDO

* open the appropriate .FRM file
lcCmd = "FileOpen (Filename: " + CHR(34) + lcFormFile + CHR(34) + ")"
DDEEXECUTE(lnDDEChan, lcCmd)

* set up for the merge

DDEEXECUTE(lnDDEChan, "MergeSelect (SelectType: All!)")
IF llWPList
   lcCmd = "MergePageBreak (State: Off!)"
ELSE
   lcCmd = "MergePageBreak (State: ON!)"
ENDIF
DDEEXECUTE(lnDDEChan, lcCmd)
=INKEY(THISFORM.nFileSaveDelay)
DO WHILE DDELastError() <> 0
   DDEEXECUTE(lnDDEChan, lcCmd)
   =INKEY(THISFORM.nFileSaveDelay)
ENDDO
* run the merge
lcCmd = "MergeRun (FormFileType: Current!; DataFileType: DataFile!; DataFile: "
lcCmd = lcCmd + CHR(34) + lcDataFile + CHR(34) + "; OutputFileType: ToFile!; OutputFile: "
lcCmd = lcCmd + CHR(34) + lcTextFile + CHR(34) + ")"
DDEEXECUTE(lnDDEChan, lcCmd)
* WE CAN PROBABLY JUST CHECK FOR THE EXISTENCE OF THE .WPD SINCE WE DELETED IT AT THE START OF
* THIS ROUTINE
DO WHILE !FILE(lcTextFile)
   =INKEY(THISFORM.nFileSaveDelay)	&& make the wait loop a bit less tight
ENDDO

DDEEXECUTE(lnDDEChan, "Close (Save: No!)")		&& close the opened .FRM file
=INKEY(.2)
DO WHILE DDELastError() <> 0
   DDEEXECUTE(lnDDEChan, "Close (Save: No!)")		&& close the opened .FRM file
   =INKEY(.2)
ENDDO

llChannelClosed = DDETERMINATE(lnDDEChan)		&& terminate the DDE connection
DO WHILE !llChannelClosed
	llChannelClosed = DDETERMINATE(lnDDEChan)
ENDDO
Hope this helps.

Marcia
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform