Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Word automation
Message
From
23/05/2012 14:02:26
 
 
To
23/05/2012 13:41:48
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Title:
Environment versions
Visual FoxPro:
VFP 9
Miscellaneous
Thread ID:
01544165
Message ID:
01544172
Views:
42
one more question:
here is my code to create a doc and type in the name address and salutaion
then I minimize vfp
then I type in Word itself
when I get out I get messeges from word to save the normal.dotm file I cancel and get several more. very anoying
#include "word10.h"
#DEFINE CR CHR(13)
#DEFINE LF CHR(11)

LOCAL lcAddress AS STRING,	;
	lcMailName AS STRING,	;
	lcSalutation AS STRING
*:Global oDocument,	 ;
oForm,				 ;
oRange,				 ;
oWord as word.application
oForm		 = oApp.GetFormObj([D_PCONTACT], [O])
lcSalutation = oForm.txtSalutation.VALUE
lcAddress	 = STRTRAN(oForm.edtAddress.VALUE, CHR(13)+CHR(10), CHR(11))
lcMailName	 = oForm.edtMailName.VALUE



oWord = CREATEOBJECT([word.application])	&& Create word object
WITH oWord
	oDocument = .documents.ADD()
	oRange	  = oDocument.RANGE()
	oRange.InsertAfter(CR)
	oRange.InsertAfter(lcMailName + LF)
	oRange.InsertAfter(lcAddress + CR + CR + CR)
	oRange.InsertAfter(lcSalutation + CR + LF)



	.ActiveDocument.SAVEAS(ADDBS(THISFORM.DocFolder) + THISFORM.DocName)
	_SCREEN.WINDOWSTATE = 1
	.VISIBLE = .T.  && Show word app
	.ACTIVATE  && Make it the active foreground app
ENDWITH
oRange	  = NULL
oDocument = NULL
oWord	  = NULL
THISFORM.RELEASE()
Peter Cortiel
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform