Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Copy contents of a general field into the clipboard
Message
 
À
04/03/2001 01:05:49
Information générale
Forum:
Visual FoxPro
Catégorie:
Contrôles ActiveX en VFP
Divers
Thread ID:
00481684
Message ID:
00481795
Vues:
15
Thanks for the reply John.... don't think our pathes have crossed since Palm Springs.

Turns out the line I really needed from you was the OLEBound.content.copy which either upsets me because I could not find it in the documentation of the OLEBoundControl or that is was not there.... thanks!

BUT, a new problem has surfaced. You will notice in the following code block that I do create the form, control, populate it and copy it to the clipboard. The process then uses my custom OLEcontrol to open Word, Open a template, find a bookmark, paste....blah, blah,blah and ends up putting the final clipboard into a patient file. Here's the problem: when Word fires up (.WordStart which uses CreateObject(word.application) or GetObject(,"word.application)) it mysteriously adds a document (Word 2000) with the contents of the clipboard in it (nasty format I might add). I thought this had to do perhaps with the native action of the OLEBoundControl so attempted to use the DoVerb() to stop the unwanted extra document window...to no avail. Try two was to simply go with it and try to close the extra document ("ActiveDocument" tried) but it was not happy either

Any ideas on getting rid of the extra document without closing Word and re-starting which is not an option for other reasons? One posibility might be to cycle somehow through all documents it thinks is open and issue close statements?

Dave

* The general field needs to be made available from within an
* OLEBoundControl since we cannot
* simply write it out with the standard .text method.
* Unfortunately the OLEBoundControl needs to be
* on a form, thus the following gyrations.....
frmWord=CREATEOBJECT("FORM") && Adds OLE object to form
frmWord.ADDOBJECT("OBJWORDDOC","OLEBOUNDCONTROL") && Sets the control source
frmWord.OBJWORDDOC.CONTROLSOURCE="cPaCDRHist.cdrh_genfld"
*frmWord.OBJWORDDOC.DoVerb(-3) && Default Word doc is 'Edit'
frmWord.OBJWORDDOC.Content.copy && Put the contents into the clipboard
Release frmWord && Clean up

* Let's get into the Word stuff
oWordObject = CreateObject("wxWordInterface") && Droege Custom Class
With oWordObject
.ResetProperties && Clean out
.Wordstart && Start it up

* for some strange reason, because of the above content.copy, WORD starts
* with a document up with the contents of the clipboard in it so I need to
* take out the trash first
*.ioWordObject.ActiveDocument.Close(.wdDoNotSaveChanges ) && Don't save

If oWordObject.ilWordStarted && property set in the .WordStart method
.icWordDocFile = lcMainPatFile && Store the Doc file to the object
.icTemplateFile = lcTemplateFile && Store the Template file to the obj

* Next open the template document in a second window
.TemplateOpen()

* Let's get the bookmarks for this note stored in Bookmarks.dbf
* and validate that they are all present in the template file
.icBookmarkTable = "Bookmarks"
.icBookmarkTableSrchField = "assocnote"
.icBookmarkTableSrchValue = "CORRECTION"
If .BookmarkValidation()

* Put the clipboard contents in the bookmark in the template,
* copy it to the clipboard and close it
lcBookMarkName = "CDRH_GENFLD"
* Move to the assocaited bookmark in the template
.ioTemplateObject.Bookmarks(lcBookMarkName ).Select
* paste the clipboard contents into the current document
.ioWordObject.selection.paste
.TemplateCopyToClipboard() && Copy the entire TEMPLATE to the clipboard
.TemplateClose() && Close the Template file

* Put the final clipboard contents into the patient document
.WordDocOpen() && Open the existing patient document
.WordDocGotoBottom() && move to the bottom
.WordDocPaste() && Write the clipboard
.ioWordObject.Activate && Put Word on top

Else
=x3WinMsg("The CDRH_GENFLD bookmark is missing in the template file!
Please add it and try again."+CHR(13)+;
"Process aborted","Bookmark missing...","!")
Return
Endif
Else && If oWordObject.ilWordStarted

=x3WinMsg("Word could not be started properly!"+CHR(13)+CHR(13)+;
"Please check with your computer support to make sure it is
loaded correctly"+CHR(13)+;
"and that the release is at least version 97 SR-2 (Service
Release 2)"+CHR(13)+CHR(13)+;
"This process will not be completed.","Word instantiation
error...",,"S")

Endif && If oWordObject.ilWordStarted

Endwith && oWordObject

* Clean up
oWordObject = .null.
Release oWordObject



>Hi Dave,
>
>This is a major PITA to figure out, but the solution is relatively simple. I have a contract printing application that grabs contract clauses from a table with a General field. To put the clauses one-by-one, I use the following method:
>
>PARAMETERS oOLEBound,oWordRange,cBoundCol,lFormat,lCRLF
>oOLEBound.ControlSource=cBoundCol
>oOLEBound.Content.Copy
>oWordRange.Collapse
>oWordRange.PasteSpecial
>IF lFormat
>   oWordRange.Text=ALLT(oWordRange.Text)+IIF(lCRLF,CHR(13),"")
>ENDIF
>RETURN
>
>This requires you to create a Form and add an OLEBoundControl to it to use as what I call oOLEBound. Also, where you want the contents of the General field, defined as a Word Range object, are required for oWordRange. cBoundCol is the name of the General field. Now note lFormat and lCRLF and what they do...not directly related to your problem but you will find you want to add spacing.
>
>Also not the PasteSpecial. If you don't use that, you'll lose most formatting.
>
>
>>I am creating Word 2000 DOC's via OLE and all works well except for getting the contents of the associated general field into the document. The contents is actually another Word DOC. My class is set up so all I need to do is get it into the clipboard and then issue a Word "paste" since I have already positioned the cursor to the correct location....
>>
>>Any ideas?
>>
>>Thanks in advance!
>>
>>Dave
************************************
Dave Kern
VP Software Development
Droege Computing Services, Inc.
Durham, NC 27705
dkern@droegecomputing.com
************************************
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform