Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
VFP 5.0 OLE Bound Control and Word'97
Message
De
23/07/1998 08:24:03
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
23/07/1998 04:34:26
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00119166
Message ID:
00120377
Vues:
17
>>>If one embbeds a Word Document and then opens it for editing thePaper Width changes. The width varies depending on the width of thecontrol.Any solutions, suggestions to overcome this problem.ThanksSonali>For inplace editing it's a problem.>-Export file to disk.>-Open word in its own window>-Replace contents>-Erase doc.>CetinHi! Thanks for the idea. Could you pls. send me some code on how to dothis ( I'm rather new to OLE ). Also will the same code work for bothWord 6 and Word 97, or how can I detect which one is there in the system.ThanksSonali
Hi Sonali,
Idea might be good but I didn't say it's cumbersome. Anyway here the implementation code :
* Form has OLEBoundControl named oOLEObj
* control.source a Gen field with embedded word doc
* This code could be a commandbutton!s click or
* cover the oOleObj with a transparent shape
* and put this in shape.dblclick
local lcTempFile
wait window nowait "Opening word..."
lcTempFile = sys(5)+curdir()+"T"+sys(2015)+".doc"
nlLocaleId=sys(3004)		&& Save local id
=sys(3006,1033)			&& We will be sending instructions in English 
thisform.oOLEobj.object.saveas(lcTempFile)
oWord = createobject("word.basic") && So don't bother if 6.0 or 8.0
* 8.0 can be called either createobject("word.basic")
* or createobject("word.application") - this one has wordbasic object 
* to use word.basic commands also (not all work as should)
with oWord
	.appshow
	.fileopen(lcTempFile)
endwith
wait clear
lnHandle = fopen(lcTempFile,12)
do while lnHandle < 0 && Suspend VFP till word exits
	lnHandle = fopen(lcTempFile,12)
enddo
=fclose(lnHandle)
release oWord
blank field WordDoc
append general WordDoc from (lcTempFile)
erase (lcTempFile)
thisform.refresh
Since used commands here work with createobject("word.basic") in versions 6.0-8.0 no need to detect version. And more it's so annoying version info is obtained differently in different versions (or someone else made appinfo$() work in both versions and I don't know how to do yet)! How would I know which one to use before I know the version is a mystery (to me) w/o using dumb workarounds such as trying to createobject("word.application") or hacking the registry. But still it's called automation.

Now drawbacks :
While this implemention works for embedded worddocs BUT any edit on a general embedded field fattens (correct word that makes fat ?) the fpt. Your fpt easily could become as 10 times of the actual size after 9-11 edits per field. So think of "linked" clause when using general fields or better just keep the path&name in a memo field. If you use linked or memo approach then instead of oleboundcontrol you may use OLEcontrol with documentfile pointing to path&name.
Another drawback is exporting and then importing is time consuming.
Hope it helps to you.
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform