Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Word Auto Expertise needed
Message
De
16/04/1999 15:38:14
 
 
À
15/04/1999 17:35:05
Information générale
Forum:
Visual FoxPro
Catégorie:
Fonctions Windows API
Divers
Thread ID:
00208789
Message ID:
00209154
Vues:
17
>Ok,
>
>Here is what I want to happen
>
>User clicks button, word opens - doc is created using data from current record - formatted, etc.
>
>So far - fine - I'm getting a good grasp on Word automation and can do the above with no problem. Now .. here is the tricky part.
>
>if user saves Word doc IN WORD - I would like VFP to somehow "know" this and do an APPEND GENERAL LINK into the table. If they close Word doc without saving, then of course, nothing happens in VFP.
>
>ideas?
>
>TIA,
>Ken

Hi ken,
I am doing olmost the same. I have a button and in the click method check if a .doc with the name 'c_'+str(primary key) exists.
If it does I use it else i set the templet to the one needed and create a file with that name (and store the name in a field)
I don't use mailmerge though, but use book marks.:

#DEFINE wdFormatDocument 0
#DEFINE wdGoToBookmark -1

LOCAL x1,oWORD,DocDir
DocDir=THISFORM.DocDir && 'c:\My Documents\Collect\'

IF NOT DIRECTORY( 'DocDir' )
MD DocDir
ENDIF


oWORD=CREATEOBJ("Word.Application")
WITH oWORD
IF EMPTY(THISFORM.kbaPage1.Page2.txtDoc.VALUE)
THISFORM.kbaPage1.Page2.txtDoc.VALUE="C0_"+PADL(THISFORM.mainIdValue,12,'0')
ENDIF
x1=DocDir+"\"+ALLTRIM(THISFORM.kbaPage1.Page2.txtDoc.VALUE)

.ChangeFileOpenDirectory( DocDir )

IF NOT EMPTY(THISFORM.kbaPage1.Page2.txtDoc.VALUE) AND FILE( DocDir + x1 +".DOC" )
.Documents.OPEN( x1 )
ELSE
DO CASE
CASE THIS.PARENT.kbaCombo2.VALUE=1
LOCAL bm1,bm2,bm3,bm4,bm5,bm6,bm7,bm8
wSys_Tab="Category='COLLACT ' AND subcat='LETTERTYPE' and value="+STR(THISFORM.kbaPage1.Page2.kbaCombo2.VALUE)
IF oApp.REQUERY('vSys_tab',;
"Category='COLLACT ' AND subcat='LETTERTYPE' and value="+;
STR(THISFORM.kbaPage1.Page2.kbaCombo2.VALUE),;
THISFORM.DATASESSIONID)>0
THISFORM.TempletType1=ALLTRIM(vSys_Tab.COMMENT)
ENDIF

.Documents.ADD (THISFORM.TempletType1, .F.,0)

*/ bookmarks defined in this templet:
*/ bm1 date
bm1=THISFORM.kbaPage1.Page2.txtDate.VALUE
bm1=CMONTH(THISFORM.kbaPage1.Page2.txtDate.VALUE)+" "+;
ALLTRIM(STR(DAY(THISFORM.kbaPage1.Page2.txtDate.VALUE)))+", "+;
ALLTRIM(STR(YEAR(THISFORM.kbaPage1.Page2.txtDate.VALUE),4,0))
.SELECTION.GOTO(wdGoToBookmark,,,'bm1')
.SELECTION.TYPETEXT( m.bm1)
*/ bm2 name
bm2=ALLTRIM(THISFORM.parentform.kbaPage1.Page2.txtCompany.VALUE)
.SELECTION.GOTO(wdGoToBookmark,,,'bm2')
.SELECTION.TYPETEXT( m.bm2)
*/ bm3 address
bm3=ALLTRIM(THISFORM.parentform.kbaPage1.Page2.edtAddress.VALUE)
.SELECTION.GOTO(wdGoToBookmark,,,'bm3')
.SELECTION.TYPETEXT( m.bm3)
*/ bm4 city,state,zip

bm4=ALLTRIM(THISFORM.parentform.kbaPage1.Page2.txtCity.VALUE)+", "+;
ALLTRIM(THISFORM.parentform.kbaPage1.Page2.txtSTATE.VALUE)+" "+;
ALLTRIM(THISFORM.parentform.kbaPage1.Page2.txtZIP.VALUE)
.SELECTION.GOTO(wdGoToBookmark,,,'bm4')
.SELECTION.TYPETEXT( m.bm4)
*/ bm5 Re:

*/ bm6 Due$
bm6=ALLTRIM(STR(THISFORM.parentform.kbaPage1.Page2.txtAmount.VALUE))
.SELECTION.GOTO(wdGoToBookmark,,,'bm6')
.SELECTION.TYPETEXT( m.bm6)
*/ bm7 Claimant
bm7=ALLTRIM( THISFORM.parentform.kbaPage1.Page2.kbaField1.VALUE)
.SELECTION.GOTO(wdGoToBookmark,,,'bm7')
.SELECTION.TYPETEXT( m.bm7)

*/ bm8 Salutation

bm8=ALLTRIM(THISFORM.parentform.kbaPage1.Page2.txtSalutation.VALUE)
.SELECTION.GOTO(wdGoToBookmark,,,'bm8')
.SELECTION.TYPETEXT( m.bm8)
*/
*/

OTHERWISE

ENDCASE
*!* THISFORM.kbaPage1.Page2.txtDoc.VALUE=x1
*!* THISFORM.kbaPage1.Page2.txtDoc.REFRESH()

.ActiveDocument.SAVEAS( x1 )



*!* x1=THIS.PARENT.edtComments.VALUE
*!* .SELECTION.GOTO(wdGoToBookmark,,,'toText')
*!* .SELECTION.TYPETEXT( x1 )

*!* .SELECTION.GOTO(wdGoToBookmark,,,'toSignature')
*!* .SELECTION.TYPETEXT( "Peter Cortiel" )
ENDIF

.VISIBLE=.T.

ENDWITH
oWORD=''
Peter Cortiel
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform