Re: ouvrir un document word à partir d'un programme cobol
- From: "James J. Gavan" <jgavandeletethis@xxxxxxx>
- Date: Sat, 25 Feb 2006 03:58:41 GMT
2jo wrote:
-----------------------
Vous êtes très tenace :-) Sacre bleu ! Tout est perdu !
I DELIBERATELY started the thread OT-Cheeses so that we wouldn't get side-tracked by Doc's comments (OT = Off Topic in this Newsgroup) - and then you go following me to that thread !!! :-) :-). So I'm back in your original thread - let's stay here !
-----------------------------------------
Thanks for all your answers
i can't do the mass-mailing using a sub in VBA so i try to do it by an
other way
i scan the word document and i replace merge fields by values
it works
i'd like to change words or expressions but to do this i have to
specify the paragraph
i give you an example of code :
move z'"Titre"' to unevar
invoke theDocument "getParagraphs" returning theParagraphs
invoke theParagraphs "item" using by value 1
returning theParagraph
invoke theParagraph "getRange" returning theRange
invoke theParagraph "finalize" returning theParagraph
invoke theParagraphs "finalize" returning theParagraphs
invoke theRange "getFind" returning theFind
invoke theFind "setForward" using by value 1
invoke theFind "setText" using by content unevar
invoke theFind "execute"
invoke theFind "getFound" returning found
invoke theFind "finalize" returning theFind
invoke theRange "select"
invoke theRange "setText" using "second"
this part of code search the text *"Titre"* in paragraph 1 and replace
it by *second* if *"Titre"* has been find
paragraph 1 is specified in this line : (invoke theFind "setForward"
using by value 1), if you want paragraph 2 you put (...using by value
2) and the same way for all other paragraphs
but what i'd like to do is to search the text in all the document and
not only in the paragraph, i think that i have to change this line : (
invoke theDocument "getParagraphs" returning theParagraphs ) and
replace getParagraphs by something else like "getDocument" but it
doesn't work...
Can you help me?
2jo
-------------------------------------
How best can I explain this. I'm going to take an existing paragraph from a Word document and using the touch-typing exercise I used while being trained in the RAF, "Now is the time for all good men to come to the aid of the party.", and insert that into a Word paragraph. As an example my "Now is...." above, note how within Mozilla Thunderbird it immediately wrapped around to a newline (CR/LF x0d0a), after "come to".
So first I'll take a paragraph from a Word document :-
----------------------------------
1. The original paragraph :
The Cheese Treeview.zip also contains the Line Sequential files Cheese.txt, Country.txt and Continent.txt from which ISAM files are initially created. The first program to be shown in your IDE should be AppBegin.cbl which is the trigger program to start the application.
----------------------------------
Next, I'll take the "Now is the time for all ........." which I'll write into Notepad as one line, and then highlight it and put it into that MS Word paragraph above after the "created." on the third line. So :-
----------------------------------------
2. The revised or "stretched" paragraph :
The Cheese Treeview.zip also contains the Line Sequential files Cheese.txt, Country.txt and Continent.txt from which ISAM files are initially created. Now is the time for all good men to come to the aid of the party.The first program to be shown in your IDE should be AppBegin.cbl which is the trigger program to start the application.
--------------------------------------------
For starters, note above I didn't copy sufficient or leave space so I get "of the party.The first program...." on the fourth line - a missing space between the period/full stop and the "T".
But far more importantly Mozilla Thunderbird for e-mail or word processors, use algorithms to MOVE text to the RIGHT when inserting additional information, and obviously calculating what to move to the next line if it doesn't fit the specified document width.
Now inserting a mailing address is not that difficult because you are inserting four or five lines with CR/LF in a specified area - BUT -
if you had text which reads :-
--------------------------------------------------------------------
We will be holding our next training session in <>, where we will be
............ doing this. The date for the training session is <>. Please book your place at our website.
----------------------------------------------------------------------
And the training session is being held at :-
the National Gallery, Trafalgar Square, London OR :-
le Musée du Louvre, Paris
then you have a problem because you can't guarantee they will be the same size - and you HAVE to MOVE to the RIGHT etc. The same could apply to the size of your next <> where you express the date and time in either English or French.
But you don't go inserting into your ORIGINAL document - unless I've missed something you must read through your original as you mentioned above and write out a temporary document, using my example above :-
-------------------------------------------------------
We will be holding our next training session in
the National Gallery, Trafalgar Square, London
, where we will be ........... doing this. The date for the training session is
Friday February 24th, 2006
.. Please book your place at our website.
------------------------------------------------------
The above of course should 'flow' elegantly from line to line not randomly like I've shown above.
Now if this is something we were using on a regular basis then if we had the time and MONEY we could patiently figure it out. However, likely as not, Bill Gates had a prime team of say 10 people working on MS Word, amply supported by some other 150 people who produced specific OO routines/methods that could be slotted into the MS Word package. You and me - deux peuple. Bill Gates 160 plus. Get the message ?
Now without seeing the complete source of what you itemised above, I couldn't begin to assess if it can work or be made to work.
Now to completely throw you for a loop - you can produce routines which possibly aren't covered elsewhere. Somebody posted a query here about how could they get rid of unnecessary spaces in a legal title. I did the following out of interest then expanded it so that I could use it. (The following OO code just *might* give you some tips).
Mon cher 2j0 - stick with MS Word mail-merge !
Jimmy
----------------------------------------------------------------
*>-------------------- InputText ---------------------------------
Program-id. InputText.
Class-Control. MakeAstring is class "makstrng".
Working-storage section.
*>******* Note : MaxLength here and in MakeAstring is set to a
*> value of 500 for testing purposes - normally MakeAstring has
*> MaxLength = 100
78 ws-MaxLength value 500.
copy "\copylib\SendStringParams.cpy"
replacing ==(tag)== by ==WS==.
copy "\copylib\ReturnStringParams.cpy"
replacing ==(tag)== by ==WS==.
01 TableA.
10 pic x(80) value " Humpty Dumpty ".
10 pic x(80) value " sat on the wall, ".
10 pic x(80) value "Humpty Dumpty".
10 pic x(80) value "had a great fall. ".
10 pic x(80) value spaces.
01 String1 Pic X(15) Value " ABCDEFGH".
01 String2 Pic X(45) Value "ABCDEFGH".
01 String3 pic x(16) value "NA North America".
01 ws-display pic zzz9.
01 os-MakeAstring object reference.
Procedure Division.
invoke MakeAstring "new" returning os-MakeAstring
initialize ws-SendStringParams
*> #1 - Humpty Dumpty
compute ws-Sendlength = function length (TableA)
*> Error Test - move 600 to ws-SendLength
set TextOneSpace to true
move TableA to ws-SendText
perform MAKE-STRING
*> #2 - Humpty Dumpty
set TextNoSpace to true
*> Error Test - move 14 to WS-Choice
perform MAKE-STRING
*> # 3 - " ABC..."
compute ws-Sendlength = function length (String1)
set TextOneSpace to true
move String1 to ws-SendText
perform MAKE-STRING
*> # 4 - "ABCDE......"
compute ws-Sendlength = function length (String2)
set TextOneSpace to true
move String2 to ws-SendText
perform MAKE-STRING
*> # 5 - Make a Treeview object label - as an object can't be
*> displayed, the resulting text is displayed instead
compute ws-Sendlength = function length (String3)
set ObjectOneSpace to true
move String3 to ws-SendText
perform MAKE-STRING
.
ABORT-PROGRAM.
display "Stop Run"
STOP RUN.
MAKE-STRING.
invoke os-MakeAString "CreateString"
using ws-SendStringParams
returning ws-ReturnStringParams
if ws-ReturnLength <> zeroes
move ws-ReturnLength to ws-display
display "Length : " ws-display
" " ws-ReturnText (1:ws-ReturnLength)
else perform ABORT-PROGRAM
End-if
.
*>--------------------------------------------------------------
*>----------------SendStringParams.cpy -------------------------
01 WS-SendStringParams.
05 WS-Choice pic x(4) comp-5 value 0.
*> Values 1 through 2 refer to strings for displayable objects
*> where x'00' is required as the final character
88 ObjectOneSpace value 1.
88 ObjectNoSpace value 2.
*> Values 3 through 4 refer to 'text' strings
88 TextOneSpace value 3.
88 TextNoSpace value 4.
88 ValidChoice value 1 thru 4.
05 WS-SendLength pic x(4) comp-5.
05 WS-SendText.
10 occurs 1 to 100
depending on WS-SendLength pic x.
*>---------------------------------------------------------------
*>---------------- ReturnStringParams.cpy --------------------
01 WS-ReturnStringParams.
05 WS-ReturnLength pic x(4) comp-5.
05 WS-ReturnObject object reference.
05 WS-ReturnText.
10 occurs 1 to ws-MaxLength
depending on WS-ReturnLength pic x.
*>------------------------------------------------------------
*>----------------- makestrng.cbl ------------------------------
*> **** 2005 Feb
*> **** If anybody makes enhancements to this Class - please let
*> **** the author know - jgavan@xxxxxxx
*> Using input data, this class :-
*> (1) creates a CharacterArray then
*> (2) uses "asArrayOfSubstrings" to ignore intervening white
*> spaces. White space in this method, is defined as being
*> any character with an ascii value that is less than
*> or equal to 32 (space).
*> (3) Builds the string setting the counters for
*> lengths of strings.
*> (4) The final string is converted to an object if required
*>--------------------------------------------------------------
Class-id. MakeAstring inherits from Base.
Class-Control. MakeAstring is class "makstrng"
CharacterArray is class "chararry"
.
*> Note : A period (.) follows the 'final' Class-Control entry
*>--------------------------------------------------------------
*>FACTORY.
*>--------------------------------------------------------------
*>END FACTORY.
*>--------------------------------------------------------------
OBJECT.
*>--------------------------------------------------------------
Method-id. "CreateString".
*>--------------------------------------------------------------
78 ws-StringLength value 80.
*>78 ws-MaxLength value 500.
78 ws-MaxLength value 100.
01 n pic x(4) comp-5.
01 ls-bytes pic x(4) comp-5.
01 ls-length pic x(4) comp-5.
01 ls-NumberOfElements pic x(4) comp-5.
01 ls-OUT-Length pic x(4) comp-5.
01 ls-OUT-Text.
10 occurs 1 to ws-MaxLength
depending on ls-OUT-Length pic x.
01 ls-Tempcount pic x(4) comp-5.
01 ls-TempText pic x(ws-StringLength).
01 ls-string object reference.
01 ls-SeparatedStrings object reference.
*** ls-SeparatedStrings is in fact an Ordered Collection
Linkage section.
copy "\copylib\SendStringParams.cpy"
replacing ==(tag)== by ==lnk==.
copy "\copylib\ReturnStringParams.cpy"
replacing ==(tag)== by ==lnk==.
Procedure Division using lnk-SendStringParams
returning lnk-ReturnStringParams.
initialize lnk-ReturnStringParams
if not ValidChoice
display "String Choice must be 1 - 4"
EXIT METHOD
End-if
if lnk-SendLength > ws-MaxLength
display "In Length exceeds MaxLength"
EXIT METHOD
End-if
initialize ls-OUT-Length, ls-OUT-Text
invoke CharacterArray "withLengthValue"
using lnk-SendLength, lnk-SendText
returning ls-String
invoke ls-String "asArrayOfSubstrings"
returning ls-SeparatedStrings
invoke ls-SeparatedStrings "size" returning ls-NumberOfElements
initialize ls-TempCount
Perform varying n from 1 by 1 until n > ls-NumberOfElements
invoke ls-SeparatedStrings "at"
using n returning ls-String
invoke ls-String "sizeinBytes" returning ls-bytes
*> Error Test - move 85 to ls-bytes
if ls-bytes > ws-StringLength
move zeroes to lnk-ReturnLength
display "String exceeds Maximum Bytes for ls-TempText"
EXIT METHOD
End-if
invoke ls-string "getValuewithSize"
using ls-bytes returning ls-TempText(1:ls-bytes)
Evaluate true
when ObjectOneSpace
when TextOneSpace
compute ls-OUT-Length
= ls-OUT-Length + ls-bytes + 1
String ls-OUT-Text (1:ls-TempCount)
ls-TempText (1:ls-bytes)
" "
into ls-OUT-Text
End-string
when other
compute ls-OUT-Length
= ls-OUT-Length + ls-bytes
String ls-OUT-Text (1:ls-TempCount)
ls-TempText (1:ls-bytes)
into ls-OUT-Text
End-string
End-Evaluate
move ls-OUT-Length to ls-TempCount
End-Perform
Evaluate true
*> Note : where 'OneSpace' this gets rid of the last extraneous
*> space character after the final PERFORM loop.
when TextOneSpace
subtract 1 from ls-OUT-Length
when ObjectOneSpace
*> add 1 to ls-OUT-Length
move x"00" to ls-OUT-Text(ls-OUT-Length:1)
when ObjectNoSpace
move x"00" to ls-OUT-Text(ls-OUT-Length:1)
End-Evaluate
move ls-OUT-Length to lnk-ReturnLength
move ls-OUT-Text to lnk-ReturnText
Evaluate true
when ObjectOneSpace
when ObjectNoSpace
invoke CharacterArray "withLengthValue"
using lnk-ReturnLength, lnk-ReturnText
returning lnk-ReturnObject
End-Evaluate
End Method "CreateString".
*>--------------------------------------------------------------
END OBJECT.
*>--------------------------------------------------------------
END CLASS MakeAstring.
*>--------------------------------------------------------------
*>--------------------------------------------------------------
.
- References:
- ouvrir un document word à partir d'un programme cobol
- From: 2jo
- Re: ouvrir un document word à partir d'un programme cobol
- From: James J. Gavan
- Re: ouvrir un document word à partir d'un programme cobol
- From: 2jo
- Re: ouvrir un document word à partir d'un programme cobol
- From: James J. Gavan
- Re: ouvrir un document word à partir d'un programme cobol
- From: 2jo
- Re: ouvrir un document word à partir d'un programme cobol
- From: 2jo
- Re: ouvrir un document word à partir d'un programme cobol
- From: James J. Gavan
- Re: ouvrir un document word à partir d'un programme cobol
- From: 2jo
- Re: ouvrir un document word à partir d'un programme cobol
- From: Michael Mattias
- Re: ouvrir un document word à partir d'un programme cobol
- From: 2jo
- ouvrir un document word à partir d'un programme cobol
- Prev by Date: Re: MF having issues?
- Next by Date: Re: Selecting common records from two files.
- Previous by thread: Re: OT : Mary Hopkin
- Next by thread: Re: ouvrir un document word à partir d'un programme cobol
- Index(es):
Relevant Pages
|