Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to print a general field ?
Message
De
14/06/2007 11:50:13
 
 
À
14/06/2007 11:47:57
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Versions des environnements
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Divers
Thread ID:
01232294
Message ID:
01233076
Vues:
9
>Some example of bookmark processing? I have never do that before.
>Thank you in advance.

Following function should give you the idea:
Function printwordwithbookmarks
Lparameters oCallobject
Local cAlias,oCatch,nCounter,cBmname,cBmvalue,oBookmark,cError,lErrorflag,cVarname
If Type('oCallobject.wordapp')<>'O' Or Isnull(oCallobject.wordapp)
	Wait Clear
	=Messagebox('Cannot Find Word Object!',0+16)
	Return .F.
Endif
If File(oCallobject.wordfilename)=.F.
	Wait Clear
	=Messagebox("Cannot Find Word File '"+Alltrim(oCallobject.wordfilename)+"'!",0+16)
	Return .F.
Endif
cAlias=oCallobject.bmalias
If Not Used(cAlias)
	Wait Clear
	=Messagebox("Cannot Find BookMark Cursor!",0+16)
	Return .F.
Endif
Try
	oCallobject.wordapp.documents.Open(oCallobject.wordfilename)
Catch To oCatch
Endtry
If Vartype(oCatch)=='O'
	=Messagebox("Cannot Open MS-Word File '"+Alltrim(oCallobject.wordfilename)+"'!",0+16)
	Return .F.
Endif
cError=On('error')
With oCallobject.wordapp.activedocument
	Select (cAlias)
	nCounter=0
	Scan
		nCounter=nCounter+1
		cBmname=Alltrim(Evaluate(cAlias+'.bmname'))
		cBmvalue=Alltrim(Evaluate(cAlias+'.bmvalue'))
		If Empty(cBmname)
			Loop
		Endif
		lErrorflag=.F.
		On Error lErrorflag=.T.
		oBookmark=.bookmarks(cBmname)
		On Error &cError.
		If lErrorflag=.T.
			Loop
		Endif
		cVarname='var'+Alltrim(Str(nCounter))
		On Error lErrorflag=.T.
		.variables.Add(cVarname)
		On Error &cError.
		If lErrorflag=.T.
			Wait Clear
			.Close(0)
			=Messagebox("Cannot Add Variable '"+cVarname+"'!",0+16)
			Return .F.
		Endif
		On Error lErrorflag=.T.
		.variables(cVarname).Value=cBmvalue
		.Fields.Add(oBookmark.Range,64,cVarname)
		On Error &cError.
		If lErrorflag=.T.
			Wait Clear
			.Close(0)
			=Messagebox("Cannot Insert Variable '"+cVarname+"'!",0+16)
			Return .F.
		Endif
		.variables(cVarname).Delete
	Endscan
	On Error lErrorflag=.T.
	.printout
	On Error &cError.
	If lErrorflag=.T.
		Wait Clear
		.Close(0)
		=Messagebox("Cannot Print From MS-Word!",0+16)
		Return .F.
	Endif
	.Close(0)
Endwith
Return
Endfunc
Edward Pikman
Independent Consultant
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform