Quantcast
Channel: Net Express / Server Express - Forum - Recent Threads
Viewing all 375 articles
Browse latest View live

class library field

$
0
0

I have a dialog screen with a text entry field (class library field).

After the first character I start a search and display a listview.

So far so good.

I want to have back the focus on that text entry field.

 

After the statement

 

SHOW-WINDOW WIN-MAT

 

I have the following statements

 

MOVE “SET-FOCUS” call-function(1)

CLEAR-CALLOUT-PARAMETERS $NULL

CALLOUT "matxtfld" 0 $NULL    (matxtfld is the modified efdemotxtfld.cbl)

It doesn’t work, maybe I have to add the Statement SET OBJECT-REF(1) , but to what?

Can someone give me a hint

Regards, Georg


RE: using .NET SDK in NetExpress 5.1

$
0
0

Allthough mi case is different, perhaps it helps you.

Our invoicing program generates an XML file.

We send all values corresponding to this invoice to a DLL program (CiberPac).

This program returns the QR-Code  as  *.bmp file

Once having this .BMP file it is easy to insert it in the invoice.

Here the example

************************************************************************

000900 01  Prog-call   PIC x(13)   vALUE "CiberPAC".

000902 01  XmlIn-xml   PIC X(26).  *>   VALUE "FACTURA.xml".

000903 01  XmlOut-xml  pic X(30).  *>   VALUE "salida.xml".

000905 01  Archivo-cer pic X(40).

000910 01  Archivo-key pic X(40).  *> "\LIC\LICENCIA.TXT"

000924 01  PasswordKey pic X(20)   VALUE z"CEDROSA-2012".

000929 01  UsuarioCiberSAT pic X(20)   VALUE z"CDR8311251R8".

002200 CALL-DLL.

002218      SET DLLNAME TO ENTRY  Prog-call   *> Apuntador a DLL

002219

002232      CALL "CiberPAC_SignXml"

002233           USING

002234           by REFERENCE  XmlIn-xml

002236           by REFERENCE  Archivo-cer

002237           by REFERENCE  Archivo-key

002238           by REFERENCE  PasswordKey

002239           by REFERENCE  XmlOut-xml

002240           by REFERENCE  UsuarioCiberSAT

002241           by REFERENCE  LlaveElectr

002242           by VALUE      nFlags      *> genera UTF-8

002249           RETURNING ID-STAT

002250           on Exception STOP "ERROR CALL".

002252

002253****************************************************

The program I use is CiberPac.

The entry point is "CiberPAC_SignXml"

The info that the program needs are in XmlIn-xml, etc.

The program delivers several files.

A log file reports if every thing worked.

If yes, I receive a file example  A-079362.xml.bmp  that is the QR-Code.

This picture is inserted in our invoices with no problem.

If this is usefull to you, but you need more info: Rolf@cedrosa.mx

RE: using .NET SDK in NetExpress 5.1

$
0
0

I used NetExpress with .Net for several years. The IDE for this product was Microsoft Visual Studio 200n.

Freundlicher Grüsse

Werner Lanter

RE: using .NET SDK in NetExpress 5.1

$
0
0

Hello Rolf,

thanks for your message.

I can't find any Information about CiberPac QR-Code in the Internet. What do I've to look for?

thanks

RE: using .NET SDK in NetExpress 5.1

$
0
0

If your using Net Express, just wrap the Managed code in a COM wrapper or make it COM visible. From Net Express you just call the component.

RE: using .NET SDK in NetExpress 5.1

$
0
0

CIBERPAC is nothing that you can use. I just mentioned it, because I suppose the general structure is simmilar:  I deliver some info to the DLL  and receive a QR-Code as a *.BMP file that I can manage afterwards and insert where I Need it.

RE: Micro Focus Server Express 5.1 WrapPack 12 - error read xml

$
0
0

Hello andcmatias,

Welcome to the Micro Focus Community Site. I have been able to reproduce the behavior you've described:

START

ERROR READ XML-FILE

XML-FILE-STATUS = -000000009

This error also occurs in the latest version of Server Express, 5.1 Wrap Pack 13.

I've found that this problem does not occur in our Visual COBOL product. If you would, please open a Support Incident for this problem, so that we can request a fix for this in Server Express. Please request that the Support Incident be assigned to Blair McDonald.

Micro Focus Server Express 5.1 WrapPack 12 - error read xml

$
0
0

I'm having trouble reading a xml, which contains the identification of tags at the root of which possesses 31 IDs (namespace). I can not change the file because it is a layout I get in a query.
I did several tests, and identified that 29 leaving only the cobol can make reading, leaving with 30 or 31 -9 error occurs (that is not in XML format) read routine.
Under a program I made an example and an example of XML.
----------------------------------------------------
example.cbl
----------------------------------------------------
$set preprocess(prexml) warn endp
IDENTIFICATION DIVISION.
PROGRAM-ID. TESTE.
ENVIRONMENT DIVISION.
CONFIGURATION SECTION.

INPUT-OUTPUT SECTION.
FILE-CONTROL.

SELECT XML-FILE ASSIGN TO "file.xml"
ORGANIZATION IS XML
DOCUMENT-TYPE IS OMITTED
FILE STATUS IS XML-FILE-STATUS.

DATA DIVISION.
FILE SECTION.
XD XML-FILE.
01 ROOT IDENTIFIED BY "root" COUNT IN ROOT-COUNT.
03 TAG1 IDENTIFIED BY "tag1" COUNT IN TAG1-COUNT.
05 DET1 PIC X IDENTIFIED BY "det1" COUNT IN DET1-COUNT.
03 TAG2 IDENTIFIED BY "tag2" COUNT IN TAG2-COUNT.
05 DET2 PIC X IDENTIFIED BY "det2" COUNT IN DET2-COUNT.
03 TAG3 IDENTIFIED BY "tag3" COUNT IN TAG3-COUNT.
05 DET3 PIC X IDENTIFIED BY "det3" COUNT IN DET3-COUNT.
03 TAG4 IDENTIFIED BY "tag4" COUNT IN TAG4-COUNT.
05 DET4 PIC X IDENTIFIED BY "det4" COUNT IN DET4-COUNT.
03 TAG5 IDENTIFIED BY "tag5" COUNT IN TAG5-COUNT.
05 DET5 PIC X IDENTIFIED BY "det5" COUNT IN DET5-COUNT.
03 TAG6 IDENTIFIED BY "tag6" COUNT IN TAG6-COUNT.
05 DET6 PIC X IDENTIFIED BY "det6" COUNT IN DET6-COUNT.
03 TAG7 IDENTIFIED BY "tag7" COUNT IN TAG7-COUNT.
05 DET7 PIC X IDENTIFIED BY "det7" COUNT IN DET7-COUNT.
03 TAG8 IDENTIFIED BY "tag8" COUNT IN TAG8-COUNT.
05 DET8 PIC X IDENTIFIED BY "det8" COUNT IN DET8-COUNT.
03 TAG9 IDENTIFIED BY "tag9" COUNT IN TAG9-COUNT.
05 DET9 PIC X IDENTIFIED BY "det9" COUNT IN DET9-COUNT.
03 TAG10 IDENTIFIED BY "tag10" COUNT IN TAG10-COUNT.
05 DET10 PIC X IDENTIFIED BY "det10" COUNT IN DET10-COUNT.
03 TAG11 IDENTIFIED BY "tag11" COUNT IN TAG11-COUNT.
05 DET11 PIC X IDENTIFIED BY "det11" COUNT IN DET11-COUNT.
03 TAG12 IDENTIFIED BY "tag12" COUNT IN TAG12-COUNT.
05 DET12 PIC X IDENTIFIED BY "det12" COUNT IN DET12-COUNT.
03 TAG13 IDENTIFIED BY "tag13" COUNT IN TAG13-COUNT.
05 DET13 PIC X IDENTIFIED BY "det13" COUNT IN DET13-COUNT.
03 TAG14 IDENTIFIED BY "tag14" COUNT IN TAG14-COUNT.
05 DET14 PIC X IDENTIFIED BY "det14" COUNT IN DET14-COUNT.
03 TAG15 IDENTIFIED BY "tag15" COUNT IN TAG15-COUNT.
05 DET15 PIC X IDENTIFIED BY "det15" COUNT IN DET15-COUNT.
03 TAG16 IDENTIFIED BY "tag16" COUNT IN TAG16-COUNT.
05 DET16 PIC X IDENTIFIED BY "det16" COUNT IN DET16-COUNT.
03 TAG17 IDENTIFIED BY "tag17" COUNT IN TAG17-COUNT.
05 DET17 PIC X IDENTIFIED BY "det17" COUNT IN DET17-COUNT.
03 TAG18 IDENTIFIED BY "tag18" COUNT IN TAG18-COUNT.
05 DET18 PIC X IDENTIFIED BY "det18" COUNT IN DET18-COUNT.
03 TAG19 IDENTIFIED BY "tag19" COUNT IN TAG19-COUNT.
05 DET19 PIC X IDENTIFIED BY "det19" COUNT IN DET19-COUNT.
03 TAG20 IDENTIFIED BY "tag20" COUNT IN TAG20-COUNT.
05 DET20 PIC X IDENTIFIED BY "det20" COUNT IN DET20-COUNT.
03 TAG21 IDENTIFIED BY "tag21" COUNT IN TAG21-COUNT.
05 DET21 PIC X IDENTIFIED BY "det21" COUNT IN DET21-COUNT.
03 TAG22 IDENTIFIED BY "tag22" COUNT IN TAG22-COUNT.
05 DET22 PIC X IDENTIFIED BY "det22" COUNT IN DET22-COUNT.
03 TAG23 IDENTIFIED BY "tag23" COUNT IN TAG23-COUNT.
05 DET23 PIC X IDENTIFIED BY "det23" COUNT IN DET23-COUNT.
03 TAG24 IDENTIFIED BY "tag24" COUNT IN TAG24-COUNT.
05 DET24 PIC X IDENTIFIED BY "det24" COUNT IN DET24-COUNT.
03 TAG25 IDENTIFIED BY "tag25" COUNT IN TAG25-COUNT.
05 DET25 PIC X IDENTIFIED BY "det25" COUNT IN DET25-COUNT.
03 TAG26 IDENTIFIED BY "tag26" COUNT IN TAG26-COUNT.
05 DET26 PIC X IDENTIFIED BY "det26" COUNT IN DET26-COUNT.
03 TAG27 IDENTIFIED BY "tag27" COUNT IN TAG27-COUNT.
05 DET27 PIC X IDENTIFIED BY "det27" COUNT IN DET27-COUNT.
03 TAG28 IDENTIFIED BY "tag28" COUNT IN TAG28-COUNT.
05 DET28 PIC X IDENTIFIED BY "det28" COUNT IN DET28-COUNT.
03 TAG29 IDENTIFIED BY "tag29" COUNT IN TAG29-COUNT.
05 DET29 PIC X IDENTIFIED BY "det29" COUNT IN DET29-COUNT.
03 TAG30 IDENTIFIED BY "tag30" COUNT IN TAG30-COUNT.
05 DET30 PIC X IDENTIFIED BY "det30" COUNT IN DET30-COUNT.
03 TAG31 IDENTIFIED BY "tag31" COUNT IN TAG31-COUNT.
05 DET31 PIC X IDENTIFIED BY "det31" COUNT IN DET31-COUNT.

WORKING-STORAGE SECTION.
01 XML-FILE-STATUS PIC S9(9) COMP.
PROCEDURE DIVISION.
DISPLAY "START"
OPEN INPUT XML-FILE
IF XML-FILE-STATUS NOT = ZEROS
DISPLAY "ERROR OPEN XML-FILE"
EXHIBIT NAMED XML-FILE-STATUS
STOP RUN
END-IF

READ XML-FILE
IF XML-FILE-STATUS < 0
DISPLAY "ERROR READ XML-FILE"
EXHIBIT NAMED XML-FILE-STATUS
STOP RUN
END-IF

DISPLAY "END"
STOP RUN.

----------------------------------------------------
file.xml
----------------------------------------------------
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<root xmlns="http://example.int/example" xmlns:t1="http://example.int/tag1" xmlns:t2="http://example.int/tag2" xmlns:t3="http://example.int/tag3" xmlns:t4="http://example.int/tag4" xmlns:t5="http://example.int/tag5" xmlns:t6="http://example.int/tag6" xmlns:t7="http://example.int/tag7" xmlns:t8="http://example.int/tag8" xmlns:t9="http://example.int/tag9" xmlns:t10="http://example.int/tag10" xmlns:t11="http://example.int/tag11" xmlns:t12="http://example.int/tag12" xmlns:t13="http://example.int/tag13" xmlns:t14="http://example.int/tag14" xmlns:t15="http://example.int/tag15" xmlns:t16="http://example.int/tag16" xmlns:t17="http://example.int/tag17" xmlns:t18="http://example.int/tag18" xmlns:t19="http://example.int/tag19" xmlns:t20="http://example.int/tag20" xmlns:t21="http://example.int/tag21" xmlns:t22="http://example.int/tag22" xmlns:t23="http://example.int/tag23" xmlns:t24="http://example.int/tag24" xmlns:t25="http://example.int/tag25" xmlns:t26="http://example.int/tag26" xmlns:t27="http://example.int/tag27" xmlns:t28="http://example.int/tag28" xmlns:t29="http://example.int/tag29" xmlns:t30="http://example.int/tag30" xmlns:t31="http://example.int/tag31">
<t1:tag1>
<t1:det1>A</t1:det1>
</t1:tag1>
</root>

----------------------------------------------------
The file below works only with 29 IDs
file.xml
----------------------------------------------------
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<root xmlns="http://example.int/example" xmlns:t1="http://example.int/tag1" xmlns:t2="http://example.int/tag2" xmlns:t3="http://example.int/tag3" xmlns:t4="http://example.int/tag4" xmlns:t5="http://example.int/tag5" xmlns:t6="http://example.int/tag6" xmlns:t7="http://example.int/tag7" xmlns:t8="http://example.int/tag8" xmlns:t9="http://example.int/tag9" xmlns:t10="http://example.int/tag10" xmlns:t11="http://example.int/tag11" xmlns:t12="http://example.int/tag12" xmlns:t13="http://example.int/tag13" xmlns:t14="http://example.int/tag14" xmlns:t15="http://example.int/tag15" xmlns:t16="http://example.int/tag16" xmlns:t17="http://example.int/tag17" xmlns:t18="http://example.int/tag18" xmlns:t19="http://example.int/tag19" xmlns:t20="http://example.int/tag20" xmlns:t21="http://example.int/tag21" xmlns:t22="http://example.int/tag22" xmlns:t23="http://example.int/tag23" xmlns:t24="http://example.int/tag24" xmlns:t25="http://example.int/tag25" xmlns:t26="http://example.int/tag26" xmlns:t27="http://example.int/tag27" xmlns:t28="http://example.int/tag28" xmlns:t29="http://example.int/tag29">
<t1:tag1>
<t1:det1>A</t1:det1>
</t1:tag1>
</root>


RE: nonexistant files in project

$
0
0

Hello Lars,

Although you are able to get a rebuild complete, it looks like the file entries in the project are corrupted.

You may want to rebuild the project (.app) file by first making a backup and then running the following command from the Net Express command prompt to rebuild the project file to a new one:

rebuild.exe OriginalProject.APP, NewProject.APP

If the above doesn't work, I would suggest recreating the project from scratch.

Regards,

RE: nonexistant files in project

$
0
0

did a rebuild but it didn´t repair the bad entries. Its a large project with different compile-settings, is there any way to import/export to facilitate a new app-file?

nonexistant files in project

$
0
0

Lately I got some strange errors (doesn´t affekt function) stating:

Dependent file not found c:\src\WinGMS\OF\     .
Rebuild complete
Dependent file not found c:\src\WinGMS\OF\       .

when running.

Among project files I have a lot nonexistant files, nameed   '.'

The can not be deleted.

Running Net Express 3.1

RE: nonexistant files in project

$
0
0

as the app is an standard index-file, is there any FD availible, the I can write a fix-program to remove the bad entries?

RE: Integração NetExpress 3.1 com MS Word

$
0
0

Hi Rogerio,

For documentation on the Word Object Model you will need to look at the VBA Docs on it:-

msdn.microsoft.com/.../ff837519.aspx

Unfortunately It is a large and complex API.

excel.if and word.if were files for using OO Vocabularies. We would advise against using them as they would be very out of date from any recent Word version. They allowed you to use a slightly different syntax. The code you supplied did not rely on a vocabulary so its best to leave commented out.

Regards

David

Integração NetExpress 3.1 com MS Word

$
0
0

Prezados Amigos,

Usei este programa como exemplo para gerar documentos no Microsoft Word:

$set ooctrl(+P) ooctrl(+Q)
*copy "word.if". *> Word vocavularies
*copy "excel.if". *> Excel vocabularies
program-id. WORDAPI.
special-names. call-convention 2 is WinApi.

Class-Control.
*-------------

WordApp is class "$OLE$word.application". *> Word 97

Working-Storage Section.
*------------------------------
77 j pic 9(003).
77 k pic 9(003).
77 wChar pic X(001).

01 WordServer object reference value null.
01 theDocuments object reference value null.
01 theDocument object reference value null.
01 theSelection object reference value null.
01 theReplacement object reference value null.
01 theParagraphs object reference value null.
01 theParagraph object reference value null.
01 theRange object reference value null.
01 theFind object reference value null.

01 wText pic X(255).

01 found pic x comp-5.
88 found-True value 45.
88 found-False value 48.

01 Program-Flags pic 9(2) comp-5 value 1.
88 New-Instance value 1 false 0.

Linkage Section.
*----------------
01 wrdParam.
05 wrdOperation pic x(008).
05 wrdFileName pic x(255).
05 wrdText pic x(255).
05 wrdChange2 pic x(255).
05 wrdSearchStatus pic x(002).
05 wordVisible pic s9(001).
05 wordSaveMode pic s9(001).

Procedure Division Using wrdParam.
******************************************************************
*
* If New-Instance
* Perform New-Set-Instance
* End-if

Evaluate wrdOperation
When 'Create'
Perform Create-Aplication
When 'Open'
Perform File-Open
When 'Delete'
Perform Delete-Selection
When 'Insert'
Perform Insert-Text
When 'Find'
Perform Find-Text
When 'Replace'
Perform Replace-Text
When 'FReplace'
* Perform Find-and-Replace-Text
Perform Find-Text
Perform Replace-Text
When 'Preview'
Perform Print-Preview
When 'Print'
Perform Print-Document
When 'Quit'
Perform Quit-Set-Instance
End-Evaluate

Exit Program
.
*----------------------------------------------------------------
Create-Aplication Section.

*> Criar uma instancia do Word
Invoke wordapp "new" Returning wordServer

*> Pega o objeto de coleção Word documents
Invoke wordServer "getDocuments" Returning theDocuments

*> Seta se o Word será visualizado
invoke wordServer "SetVisible" using by value wordVisible
.
*----------------------------------------------------------------
File-Open Section.

*> Abre o arquivo em wrdFileName
Invoke theDocuments "Open" Using wrdFileName

*> Pega o documento ativo
Invoke wordServer "getActiveDocument" Returning theDocument
.
*----------------------------------------------------------------
Delete-Selection Section.

* invoke wordServer "getSelection" returning theSelection
* invoke theSelection "Delete"

*> Seleciona o texto encontrado
invoke theRange "select"

*> 'CUTila' o texto encontrado
invoke theRange "Cut"
.
*----------------------------------------------------------------
Insert-Text Section.

* Move wrdChange2 to wText

* Perform Null-Terminate-Routine
* Move wText to wrdChange2
* invoke wordServer "getSelection" returning theSelection
* invoke theSelection "InsertAfter" using by content wrdChange2

*> Insere o texto
invoke theRange "InsertAfter" using by content wrdChange2
.
*----------------------------------------------------------------
Find-Text Section.

Move "23" to wrdSearchStatus
Move wrdText to wText

Perform Null-Terminate-Routine

Move wText to wrdText

*> Pega o objeto Range
Invoke theDocument "getContent" returning theRange

*> Pega o objecto Find
Invoke theRange "getFind" returning theFind

*> A procura será para frente
Invoke theFind "setForward" using by value 1

*> A busca sera pelo conteudo de wrdText
Invoke theFind "setText" using by content wrdText

*> Procurar
Invoke theFind "execute"

*> Encontrou ?
Invoke theFind "getFound" returning found

*> Se encontrou...
if found-True
move "00" to wrdSearchStatus
end-if
.
*----------------------------------------------------------------
Find-and-Replace-Text Section.

Move "23" to wrdSearchStatus
Move wrdText to wText

Perform Null-Terminate-Routine

Move wText to wrdText
Move wrdChange2 to wText

Perform Null-Terminate-Routine

Move wText to wrdChange2

*> Pega o objeto Range
Invoke theDocument "getContent" returning theRange

*> Pega o objecto Find
Invoke theRange "getFind" Returning theFind

*> A procura será para frente
Invoke theFind "getReplacement" Returning theReplacement

Invoke theFind "setForward" Using by value 1
*> A busca sera pelo conteudo de wrdText

Invoke theFind "setText" Using by content wrdText
Invoke theReplacement "setText" Using by content wrdChange2

*> Procurar
* Invoke theFind "setReplace" Using by value 1
Invoke theFind "execute"

*> Encontrou ?
Invoke theFind "getFound" returning found

*> Se encontrou...
if found-True
move "00" to wrdSearchStatus
end-if
.
*----------------------------------------------------------------
Replace-Text Section.

Move wrdChange2 to wText

Perform Null-Terminate-Routine

Move wText to wrdChange2
subtract 01 from k

*> Seleciona o texto encontrado
invoke theRange "select"

*> Finalmente, muda o texto encontrado (wrdText)
*> para o desejado
invoke theRange "Cut"
move 00 to j
invoke theRange "InsertAfter" using " "
perform until j = k
add 01 to j
move wrdChange2(j:1) to wChar
invoke theRange "InsertAfter" using by content wChar
end-perform

*> Não preciso mais dos objetos Find e Range
Invoke theFind "finalize" returning theFind
Invoke theRange "finalize" returning theRange
.
*----------------------------------------------------------------
Print-Preview Section.

invoke theDocument "PrintPreview"
.
*----------------------------------------------------------------
Print-Document Section.

invoke theDocument "PrintOut" using by value 0
.
*----------------------------------------------------------------
New-Set-Instance Section.

set New-Instance to false
.
*----------------------------------------------------------------
Null-Terminate-Routine Section.

move length of wText to j

perform varying k from j by -1
until k = 0

if wText(k:1) not = spaces and not = X"00"
add 01 to k
move x"00" to wText(k:1)
exit section
end-if

end-perform

move x"00" to wText(j:1)
.
*----------------------------------------------------------------
Size-Of-String Section.

move length of wText to j

perform varying k from j by -1
until k = 0
or wtext(k:1) not = spaces and x"00"
end-perform
.
*----------------------------------------------------------------
Quit-Set-Instance Section.

*> Fechar o arquivo sem salvando-o
if wordSaveMode = 0
Invoke theDocument "Close" Using by value 0
else
if wordSaveMode = -1
Invoke theDocument "Close" Using by value -1
end-if
end-if

*> Finalizar o objecto de coleção Documents
Invoke theDocuments "finalize" Returning theDocuments

*> Tell Word to quit (it won't shut down otherwise)
Invoke wordServer "quit"

*> Finalizar o Word
Invoke wordServer "finalize" Returning wordServer
.

1 - Como descubro todos os métodos da classe wordapp ?

2 - Onde encontro o arquivo "word.if" , definido no inicio do programa ?

Atenciosamente

Rogerio Barbosa Ferreira

RE: Integração NetExpress 3.1 com MS Word

$
0
0

Eu estou construindo uma classe para facilitar o uso da WORD API

Ainda está precária, mas já tem as funções mais comuns.

Copy and enjoy.

=============================================================

     $set ooctrl(+P)

     *-----------------------------------------------------------------*

     * Modulo : cblWrdAPI                                              *

     * Função :                                                        *

     *                                                                 *

     * Se este código não funcionar, nem imagino que o escreveu, porem,*

     * se funcionar, ele foi escrito por:                              *

     *-----------------------------------------------------------------*

     *                                     .-----,                     *

     *                          __    o   /        __         _  __    *

     *                          __)   |   `-----,  __) |  | |/  |  |   *

     *                         |  |   |        /  |  | |  | |   |  |   *

     *                         `--'`--' `-----'   `--' `--' '   `--'   *

     * Sertanejo, tô fora!                         ajsauro@gmail.com   *

     *-----------------------------------------------------------------*

     * Pede-se a gentileza de, caso alguém venha a alterar ou incluir  *

     * função, enviar a mesma para o e-mail acima.                     *

     *-----------------------------------------------------------------*

     *******************************************************************

      class-id.    cblWrdAPI data is protected

                             inherits from Base

                             .

     *------------------------------

      object                 section.

     *------------------------------

      Class-Control.

     *-------------

      *> Native Object COBOL classes

          olesup is class "olesup"           *> OLE support class

     *

          cblWrdAPI is class "cblWrdAPI"

          WordApp is class "$OLE$word.application"

          cStrUtil is class 'cblStrUtil'

          .

     *------------------------------

      Working-Storage        Section.

     *------------------------------

     /    COPY     'msword.CPY'.

      01 WdOrientation    pic s9(9) comp-5 typedef.

         88 wdOrientPortrait           VALUE 0.

         88 wdOrientLandscape          VALUE 1.

     *

      01 WdSeekView    pic s9(9) comp-5. *> typedef.

         88 wdSeekMainDocument         VALUE 0.

         88 wdSeekPrimaryHeader        VALUE 1.

         88 wdSeekFirstPageHeader      VALUE 2.

         88 wdSeekEvenPagesHeader      VALUE 3.

         88 wdSeekPrimaryFooter        VALUE 4.

         88 wdSeekFirstPageFooter      VALUE 5.

         88 wdSeekEvenPagesFooter      VALUE 6.

         88 wdSeekFootnotes            VALUE 7.

         88 wdSeekEndnotes             VALUE 8.

         88 wdSeekCurrentPageHeader    VALUE 9.

         88 wdSeekCurrentPageFooter    VALUE 10.

     *

      01 WdPaperSize    pic s9(9) comp-5. *> typedef.

         88 wdPaper10x14               VALUE 0.

         88 wdPaper11x17               VALUE 1.

         88 wdPaperLetter              VALUE 2.

         88 wdPaperLetterSmall         VALUE 3.

         88 wdPaperLegal               VALUE 4.

         88 wdPaperExecutive           VALUE 5.

         88 wdPaperA3                  VALUE 6.

         88 wdPaperA4                  VALUE 7.

         88 wdPaperA4Small             VALUE 8.

         88 wdPaperA5                  VALUE 9.

         88 wdPaperB4                  VALUE 10.

         88 wdPaperB5                  VALUE 11.

         88 wdPaperCSheet              VALUE 12.

         88 wdPaperDSheet              VALUE 13.

         88 wdPaperESheet              VALUE 14.

         88 wdPaperFanfoldLegalGerman  VALUE 15.

         88 wdPaperFanfoldStdGerman    VALUE 16.

         88 wdPaperFanfoldUS           VALUE 17.

         88 wdPaperFolio               VALUE 18.

         88 wdPaperLedger              VALUE 19.

         88 wdPaperNote                VALUE 20.

         88 wdPaperQuarto              VALUE 21.

         88 wdPaperStatement           VALUE 22.

         88 wdPaperTabloid             VALUE 23.

         88 wdPaperEnvelope9           VALUE 24.

         88 wdPaperEnvelope10          VALUE 25.

         88 wdPaperEnvelope11          VALUE 26.

         88 wdPaperEnvelope12          VALUE 27.

         88 wdPaperEnvelope14          VALUE 28.

         88 wdPaperEnvelopeB4          VALUE 29.

         88 wdPaperEnvelopeB5          VALUE 30.

         88 wdPaperEnvelopeB6          VALUE 31.

         88 wdPaperEnvelopeC3          VALUE 32.

         88 wdPaperEnvelopeC4          VALUE 33.

         88 wdPaperEnvelopeC5          VALUE 34.

         88 wdPaperEnvelopeC6          VALUE 35.

         88 wdPaperEnvelopeC65         VALUE 36.

         88 wdPaperEnvelopeDL          VALUE 37.

         88 wdPaperEnvelopeItaly       VALUE 38.

         88 wdPaperEnvelopeMonarch     VALUE 39.

         88 wdPaperEnvelopePersonal    VALUE 40.

         88 wdPaperCustom              VALUE 41.

     *

      77           j                   pic 9(003).

      77           k                   pic 9(003).

      77           wChar               Pic X(001).

      78           mfUtil              value 'mfUtil'.

     *

      01           lsParametro.

        05         lsFuncao            PIC X(030).

        05         lsSubFuncao         PIC X(030).

        05         lsStatus            PIC X(002).

        05         lsSizeOfString      PIC 9(003).

        05         lsPalavras          PIC 9(003).

        05         lsChar1             PIC X(001).

        05         lsChar2             PIC X(001).

        05         lsString.

          10       lsSChar             PIC X(001) Occurs 256.

        05         lsString2.

          10       lsSChar2            PIC X(001) Occurs 256.

      01           found               pic x comp-5.

        88         found-True          value 45.

        88         found-False         value 48.

      01           Program-Flags       PIC 9(2) COMP-5 VALUE 1.

        88         New-Instance        VALUE 1 FALSE 0.

     */////////////////////////////////////////////////////////////////

      Class-Object.

      Object-Storage         Section.

      method-id. "CriarObjeto".

      linkage section.

      77           lnkWrdAPP           object reference.

     ******************************************************************

      Procedure              Division  Returning lnkWrdAPP.

     ******************************************************************

          invoke   super "new" returning lnkWrdAPP

          exit method

          .

      end method "CriarObjeto".

      End Class-Object.

     */////////////////////////////////////////////////////////////////

     *

      Object.

     *------------------------------

      Object-Storage         Section.

     *------------------------------

      77           cblStrUtil          Object Reference Value Null.

     *

      01           wText               Pic X(255).

      01           WordServer          object reference value null.

      01           theActiveWindow     Object Reference value NULL.

      01           theActivePane       Object Reference value NULL.

      01           theView             Object Reference value NULL.

      01           theTypeText         Object Reference value NULL.

      01           theDocuments        object reference value null.

      01           theDocument         object reference value null.

      01           theSelection        object reference value null.

      01           PageSetup           Object Reference value NULL.

      01           theReplacement      object reference value null.

      01           theParagraphs       object reference value null.

      01           theParagraph        object reference value null.

      01           theRange            object reference value null.

      01           theFind             object reference value null.

      01           theFont             object reference value null.

     *------------------------------

      Method-Id. "CreateAplication".

     *------------------------------

      Local-Storage          Section.

     *------------------------------

      Linkage                Section.

     *------------------------------

      01           wordVisible         pic s9(001).

     ******************************************************************

      Procedure              Division Using wordVisible.

     ******************************************************************

          *> Set the timeout for the OLE "busy" error to 100ms

          *> Using this method is recommended for Word applications

          Invoke olesup "setOLEBusyTimeout" using by value 100

          *> Criar uma instancia do Word

          Invoke   wordapp "new"       Returning wordServer

          *> Seta se o Word será visualizado

          invoke   wordServer "SetVisible" using by value wordVisible

          If       cblStrUtil          Is Equal Null

                   Invoke cStrUtil "CriarObjeto" Returning cblStrUtil

          End-If

          Exit     Method

          .

      End Method "CreateAplication".

     *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*

     *                                                                 *

     *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*

      Method-id. "A4".

     *******************************************************************

      Procedure              division.

     *******************************************************************

          Set      wdPaperA4           to TRUE

          Invoke   PageSetup "setPaperSize" Using WdPaperSize

          Exit     Method

          .

      End method "A4".

     *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*

     * Pegar a orientação da pagina                                    *

     *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*

      method-id. "getPageOrientation".

      linkage section.

      01           Orientation         WdOrientation.

      procedure division returning Orientation.

          Invoke   PageSetup "getOrientation" returning Orientation

          Exit     Method

          .

      end method "getPageOrientation".

     *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*

     * Setar a orientação da página para o modo "Retrato"              *

     *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*

      Method-id. "Retrato".

     *******************************************************************

      Procedure              division.

     *******************************************************************

          Invoke   SELF "Portrait"

          Exit     Method

          .

      End method "Retrato".

     *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*

     * Setar a orientação da página para o modo "Retrato"              *

     *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*

      Method-id. "Portrait".

     *------------------------------

      Local-Storage          section.

     *------------------------------

      01           Orientation         WdOrientation.

     *******************************************************************

      Procedure              division.

     *******************************************************************

          Set      wdOrientPortrait of Orientation to TRUE

          Invoke   PageSetup "setOrientation" Using Orientation

          Exit     Method

          .

      End method "Portrait".

     *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*

     * Setar a orientação da página para o modo "Paisagem"             *

     *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*

      Method-id. "Paisagem".

     *******************************************************************

      Procedure              division.

     *******************************************************************

          Invoke   SELF "Landscape"

          Exit     Method

          .

      End method "Paisagem".

     *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*

     * Setar a orientação da página para o modo "Paisagem"             *

     *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*

      Method-id. "Landscape".

     *------------------------------

      Local-Storage          section.

     *------------------------------

      01           Orientation         WdOrientation.

     *******************************************************************

      Procedure              division.

     *******************************************************************

          Set      wdOrientLandscape of Orientation to TRUE

          Invoke   PageSetup "setOrientation" Using Orientation

          Exit     Method

          .

      End method "Landscape".

     *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*

     *                                                                 *

     *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*

      Method-Id. "SetVisible".

     *------------------------------

      Linkage                Section.

     *------------------------------

      01           wordVisible         pic s9(001).

     ******************************************************************

      Procedure              Division  Using wordVisible.

     ******************************************************************

          *> Seta se o Word será visualizado

          Invoke   wordServer "SetVisible" using by value wordVisible

          Exit     Method

          .

      End Method "SetVisible".

     *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*

     *                                                                 *

     *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*

      Method-Id. "Add".

     ******************************************************************

      Procedure              Division.

     ******************************************************************

          *> Pega o objeto de coleção Word documents

          Invoke   wordServer "getDocuments" Returning theDocuments

          Invoke   theDocuments "Add"

          Invoke   theDocuments "finalize" returning theDocuments

          Invoke   wordServer "getSelection" returning theSelection

          *> Pega o objeto PageSetup

          Invoke   theSelection "getPageSetup" returning PageSetup

          Invoke   theSelection "getParagraphFormat"

                                       returning theParagraph

          Invoke   theParagraph "setSpaceAfter" Using by value 0

          Invoke   theSelection "getFont" returning theFont

          Invoke   theFont "setName" Using z"Courier New"

          Invoke   theFont "setSize" Using by value 8

          Invoke   theFont "Finalize" returning theFont

          Exit     Method

          .

      End Method "Add".

     *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*

     *                                                                 *

     *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*

      method-id. "WholeStory".

     ******************************************************************

      procedure              division.

     ******************************************************************

          Invoke   wordServer "getSelection" returning theSelection

          invoke   theSelection "WholeStory"

          Invoke   theSelection "Finalize" returning theSelection

          Exit     Method

          .

      end method "WholeStory".

     *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*

     *                                                                 *

     *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*

      Method-Id. "SeekCurrentPageHeader".

     ******************************************************************

      Procedure              Division.

     ******************************************************************

          *> Pega o objeto de coleção Word documents

          Invoke   wordServer "getActiveWindow"

                                       Returning theActiveWindow

          Invoke   theActiveWindow "getActivePane"

                                             Returning theActivePane

          Invoke   theActivePane "getView" returning theView

          Set      wdSeekCurrentPageHeader to true

          Invoke   theView "setSeekView" Using WdSeekView

          Invoke   theActivePane "getSelection" Returning theSelection

          Invoke   theSelection "getFont" returning theFont

          Invoke   theFont "setName" Using z"Courier New"

          Invoke   theFont "setSize" Using by value 8

          Invoke   theFont "Finalize" returning theFont

          Invoke   theActiveWindow "Finalize" returning theActiveWindow

          Invoke   theActivePane   "Finalize" returning theActivePane

          Exit     Method

          .

      End Method "SeekCurrentPageHeader".

     *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*

     *                                                                 *

     *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*

      method-id. "FileOpen".

     *------------------------------

      local-storage          Section.

     *------------------------------

      linkage                Section.

     *------------------------------

      01           wrdFileName         Pic X(255).

     ******************************************************************

      procedure              division using wrdFileName.

     ******************************************************************

          *> Abre o arquivo em wrdFileName

          Invoke   theDocuments "Open" Using wrdFileName

          *> Pega o documento ativo

          Invoke   wordServer "getActiveDocument" Returning theDocument

          exit     method

          .

      End method "FileOpen".

     */////////////////////////////////////////////////////////////////

      Method-id. "SaveAs".

     *------------------------------

      Local-storage          Section.

     *------------------------------

      Linkage                Section.

     *------------------------------

      01           wrdFileName         Pic X(255).

     ******************************************************************

      Procedure              Division  Using wrdFileName.

     ******************************************************************

          Move     'NullTerminate'     to lsFuncao

          Move     wrdFileName         to lsString

          MOVE     LENGTH OF lsString  to lsSizeOfString

          move     ' '                 to lsChar1 lsChar2

          CALL     mfUtil              Using lsParametro

          Move     lsString            to wrdFileName

          Invoke   theDocuments "FileSaveAs" Using wrdFileName

          Exit     Method

          .

      End Method "SaveAs".

     *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*

     * Exportar para PDF                                               *

     *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*

      method-id. "ExportarParaPDF".

     *------------------------------

      local-storage          Section.

     *------------------------------

      linkage                Section.

     *------------------------------

      01           pdfFileName         Pic X(255).

     ******************************************************************

      Procedure              Division  Using pdfFileName.

     ******************************************************************

          Invoke   SELF "ExportToPDF"  Using pdfFileName

          Exit     Method

          .

      End Method "ExportarParaPDF".

     *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*

     * Exportar para PDF                                               *

     *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*

     *method-id. "ExportToPDF".

     *------------------------------

     *local-storage          Section.

     *------------------------------

     *linkage                Section.

     *------------------------------

     *01           pdfFileName         Pic X(255).

     ******************************************************************

     *Procedure              Division  Using pdfFileName.

     ******************************************************************

     *      ChangeFileOpenDirectory "C:\Users\Usuário\Desktop\"

     *      ActiveDocument.ExportAsFixedFormat OutputFileName:= _

     *          "C:\Users\Usuário\Desktop\sgfdsfg.pdf", ExportFormat:=wdExportFormatPDF, _

     *          OpenAfterExport:=True, OptimizeFor:=wdExportOptimizeForPrint, Range:= _

     *          wdExportAllDocument, From:=1, To:=1, Item:=wdExportDocumentContent, _

     *          IncludeDocProps:=True, KeepIRM:=True, CreateBookmarks:= _

     *          wdExportCreateNoBookmarks, DocStructureTags:=True, BitmapMissingFonts:= _

     *          True, UseISO19005_1:=False

     *

     *    Exit     Method

     *    .

     *End Method "ExportToPDF".

     */////////////////////////////////////////////////////////////////

      method-id. "DeleteSelection".

     *------------------------------

      local-storage          Section.

     *------------------------------

      linkage                Section.

     *------------------------------

     ******************************************************************

      procedure              division.

     ******************************************************************

     *    invoke wordServer "getSelection" returning theSelection

     *    invoke theSelection "Delete"

          *> Seleciona o texto encontrado

          invoke   theRange "select"

          *> 'CUTila' o texto encontrado

          invoke   theRange "Cut"

          exit     method

          .

      end method "DeleteSelection".

     */////////////////////////////////////////////////////////////////

      method-id. "NewLine".

     ******************************************************************

      procedure              division.

     ******************************************************************

          *> Insere o texto

          invoke   theSelection "InsertAfter" using z" "

          exit     method

          .

      end method "NewLine".

     *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*

     *                                                                 *

     *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*

      Method-Id. "setPageHeader".

     *------------------------------

      linkage                Section.

     *------------------------------

      01           wrdText             Pic X(256).

     ******************************************************************

      procedure              division using wrdText.

     ******************************************************************

          Invoke   SELF "SeekCurrentPageHeader"

     *    Invoke   cblStrUtil "NullTerminate" Using wrdText

          *>Invoke   theSelection "setText" Using wrdText

     *    Invoke   SELF "InsertText" Using wrdText

     *    Set      wdSeekMainDocument    to true

     *    Invoke   theView "setSeekView" Using WdSeekView

     *

     *    Invoke   theView         "Finalize" returning theView

     *

          Exit     Method

          .

      End Method "setPageHeader".

     *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*

     *                                                                 *

     *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*

      Method-Id. "EndPageHeader".

     ******************************************************************

      Procedure              Division.

     ******************************************************************

          Set      wdSeekMainDocument    to true

          Invoke   theView "setSeekView" Using WdSeekView

          Invoke   theView         "Finalize" returning theView

          Exit     Method

          .

      End Method "EndPageHeader".

     *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*

     *                                                                 *

     *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*

      method-id. "InsertText".

     *------------------------------

      local-storage          Section.

     *------------------------------

      linkage                Section.

     *------------------------------

      01           wrdText             Pic X(256).

     ******************************************************************

      procedure              division using wrdText.

     ******************************************************************

          Invoke   cblStrUtil "NullTerminate" Using wrdText

          *> Insere o texto

          Invoke   theSelection "TypeText" using by content wrdText

          Exit     Method

          .

      end method "InsertText".

     *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*

     *                                                                 *

     *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*

      method-id. "TypeParagraph".

     *------------------------------

      local-storage          Section.

     *------------------------------

      linkage                Section.

     *------------------------------

      01           wrdText             Pic X(256).

     ******************************************************************

      procedure              division using wrdText.

     ******************************************************************

          Invoke   theSelection "TypeParagraph"

          Exit     Method

          .

      end method "TypeParagraph".

     */////////////////////////////////////////////////////////////////

      method-id. "FindText".

     *------------------------------

      local-storage          Section.

     *------------------------------

      linkage                Section.

     *------------------------------

      01           wrdText             Pic X(255).

      01           wrdSearchStatus     Pic X(002).

     ******************************************************************

      procedure              division using wrdText,

                                  returning wrdSearchStatus.

     ******************************************************************

          Move     "23"                To wrdSearchStatus

          Move     'NullTerminate'     to lsFuncao

          Move     wrdText             to lsString

          MOVE     LENGTH OF lsString  TO lsSizeOfString

          move     ' '                 to lsChar1 lsChar2

          CALL     mfUtil              USING lsParametro

          Move     lsString            to wrdText

          Invoke   Self 'GetTheRange'

          *> Pega o objecto Find

          Invoke   theRange "getFind"   Returning theFind

          *> A procura será para frente

          Invoke   theFind "setForward" Using by value 1

          *> A busca sera pelo conteudo de wrdText

          Invoke   theFind "setText"    Using by content wrdText

          *> Para que a operação de localização localize somente

          *> palavras inteiras, e não texto que seja parte de uma

          *> palavra maior.

     *    Invoke   theFind 'setMatchWholeWord' using by value 1

          *> Procurar

          Invoke   theFind "execute"

          *> Encontrou ?

          Invoke   theFind "getFound"  Returning found

          *> Se encontrou...

          If       found-True

                   Move "00"           To wrdSearchStatus

          End-if

          exit     method

          .

      end method "FindText".

     */////////////////////////////////////////////////////////////////

      method-id. "ReplaceText".

     *------------------------------

      local-storage          Section.

     *------------------------------

      linkage                Section.

     *------------------------------

      01           wrdChange2          Pic X(255).

     *******************************************************************

      procedure              division using wrdChange2.

     *******************************************************************

          Move     'TamanhoSTR'        to lsFuncao

          MOVE     LENGTH OF wrdChange2 TO lsSizeOfString

          MOVE     wrdChange2          TO lsString

          CALL     mfUtil              USING lsParametro

          *> Seleciona o texto encontrado

          invoke   theRange "select"

          *> Finalmente, muda o texto encontrado (wrdText)

          *> para o desejado

          invoke   theRange "Cut"

          MOVE     ZEROS               TO j

          Move     lsSizeOfString      to k

          perform  until j             = k

                   add 01              to j

                   move wrdChange2(j:1) to wChar

                   invoke theRange "InsertAfter" using by content wChar

          end-perform

          *> Não preciso mais dos objetos Find e Range

          Invoke   theFind "finalize"  Returning theFind

          Invoke   theRange "finalize" Returning theRange

          exit     method

          .

      end method "ReplaceText".

     */////////////////////////////////////////////////////////////////

      method-id. "FindAndReplaceText".

     *------------------------------

      local-storage          Section.

     *------------------------------

      linkage                Section.

     *------------------------------

      01           wrdText             Pic X(255).

      01           wrdChange2          Pic X(255).

      01           wrdSearchStatus     Pic X(002).

     *******************************************************************

      procedure              division using wrdText,

                                            wrdChange2,

                                  returning wrdSearchStatus.

     *******************************************************************

          Move     "23"                To wrdSearchStatus

          Move     'TamanhoSTR'        to lsFuncao

          Move     wrdChange2          to lsString

          CALL     mfUtil              USING lsParametro

          Move     lsSizeOfString      to k

          Move     'NullTerminate'     to lsFuncao

          CALL     mfUtil              USING lsParametro

          Move     lsString            to wrdChange2

          Move     wrdText             to lsString

          MOVE     LENGTH OF lsString  TO lsSizeOfString

          CALL     mfUtil              USING lsParametro

          Move     lsString            to wrdText

          Invoke   Self 'GetTheRange'

          *> Pega o objecto Find

          Invoke   theRange "getFind"   Returning theFind

     /    Invoke   theFind "getReplacement"   Returning theReplacement

          *> A procura será para frente

          Invoke   theFind "setForward" Using by value 1

          *> A busca sera pelo conteudo de wrdText

          Invoke   theFind "setText"    Using by content wrdText

     /    Invoke   theReplacement "setText" Using by content wrdChange2

          *> Procurar

          Invoke   theFind "execute"

          *> Encontrou ?

          Invoke   theFind "getFound"  Returning found

          invoke   theFind "finalize"  Returning theFind

          *> Se encontrou...

          If       found-True

                   Move "00"           To wrdSearchStatus

                   invoke theRange "select"

                   invoke theRange "setText" using

                                       by content wrdChange2(1:k)

          End-if

          exit     method

          .

      end method "FindAndReplaceText".

     */////////////////////////////////////////////////////////////////

      method-id. "GetTheRange".

     *------------------------------

      local-storage          Section.

     *------------------------------

      linkage                Section.

     *------------------------------

     *******************************************************************

      procedure              division.

     *******************************************************************

          *> Pega o objeto Range

          Invoke   theDocuments "getContent" returning theRange

          exit     method

          .

      end method "GetTheRange".

     */////////////////////////////////////////////////////////////////

      method-id. "PrintPreview".

     *------------------------------

      local-storage          Section.

     *------------------------------

      linkage                Section.

     *------------------------------

     *******************************************************************

      procedure              division.

     *******************************************************************

          invoke   theDocument "PrintPreview"

          exit     method

          .

      end method "PrintPreview".

     */////////////////////////////////////////////////////////////////

      method-id. "PrintDocument".

     *------------------------------

      local-storage          Section.

     *------------------------------

      linkage                Section.

     *------------------------------

     *******************************************************************

      procedure              division.

     *******************************************************************

          invoke   theDocument "PrintOut" using by value 0

          exit     method

          .

      end method "PrintDocument".

     */////////////////////////////////////////////////////////////////

      method-id. "QuitCloseFile".

     *------------------------------

      local-storage          Section.

     *------------------------------

      linkage                Section.

     *------------------------------

      01           wordSaveMode        pic s9(001).

     *******************************************************************

      procedure              division using wordSaveMode.

     *******************************************************************

          *> Fechar o arquivo...

          If       wordSaveMode        = 0

             *>...sem salva-lo

                   Invoke theDocument "Close" Using by value 0

          Else

           If      wordSaveMode        = -1

             *>...salvando-o

                   Invoke theDocument "Close" Using by value -1

           End-if

          End-if

          Invoke   theDocument "finalize" Returning theDocument

          exit     method

          .

      end method "QuitCloseFile".

     */////////////////////////////////////////////////////////////////

      method-id. "Quit".

     *------------------------------

      local-storage          Section.

     *------------------------------

      linkage                Section.

     *------------------------------

     *******************************************************************

      procedure              division.

     *******************************************************************

          *> Finalizar o objecto de coleção Documents

          Invoke   theDocuments "finalize" Returning theDocuments

          *> Tell Word to quit (it won't shut down otherwise)

          Invoke   wordServer "quit"

          *> Finalizar o Word

          Invoke   wordServer "finalize" Returning wordServer

          .

      end method "Quit".

     *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*

     *               Finalizar as classes usadas                       *

     *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*

      Method-Id. "Finalize".

     *------------------------------

      Linkage                Section.

     *------------------------------

      77           lnkObjeto           object reference.

     *******************************************************************

      Procedure              Division  Returning lnkObjeto.

     *******************************************************************

          Invoke   cblStrUtil "Finalize" returning cblStrUtil

          If       WordServer          not equal null

                   Invoke WordServer "Finalize" returning WordServer

          End-If

          Invoke   SUPER "Finalize" Returning lnkObjeto

          Exit     Method

          .

      End Method "Finalize".

     *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

      End Object.

     *//////////////////////////////////////////////////////////////////

      End Class    cblWrdAPI.

     ******************************************************************

How ca*n I reset the currect Selection in Microsoft Word from COBOL

Proble*m:

     *

If you*are using the "InsertAfter" method of the selection object to enter text into a Word document then the selection is expanded with the new text.

     *

This c*n cause problems when you jsut want to apply formatting (Bold etc) to some of the text. If you apply Bold then it applies to all the selection.

     *

Resolu*ion:

     *

You ca* use the "Collapse" method of the selection object reset the selection down to just the current text entry position. Some example code to perform this is:-

     *

     *   *> Here we want to do collapse and bold the next text

     *

     *    set wdCollapseEnd of ws-direction to true

     *

     *    invoke theSelection "Collapse" using ws-direction

     *

     *    invoke theSelection "InsertAfter" using

     *

     *   "This is some text that need to be bold" & x"0d"

     *

     *    invoke theSelection "getFont" returning theFont

     *

     *    set Size-CBL  to 12

     *

     *    invoke theFont "setSize" using by value Size-CBL

     *

     *    set Size-CBL  to 1

     *

     *    invoke theFont "setBold" using by value Size-CBL

     *

     *    invoke theFont "setUnderline" using by value Size-CBL

     *

     *    invoke theFont "finalize"  returning theFont

     *

     *    invoke theSelection "finalize" returning theSelection

     *

For fu*l details on the "Collapse" method please see the help provided with Microsoft Word.


RE: Integração NetExpress 3.1 com MS Word

RE: Integração NetExpress 3.1 com MS Word

$
0
0

Prezado Antonio,

Obrigado pela colaboração. Vou testar suas rotinas e te dou retorno em breve.

Vou te dizer o que estou fazendo.

Eu crio um documento no Word e onde tenho que inserir meus dados eu coloco um texto (&01, &02) e depois vou substituindo os mesmos pelos dados reais.

Me deparei com um problema onde tenho que inserir a foto de um determinado funcionário no documento.

No word é mole: inserir > image > e escolho a imagem que eu quero. Mas e em tempo de execução?

Você sabe quais são todos os métodos dessa classe do word?

Mais uma vez obrigado pela colaboração.

Atenciosamente

Rogerio Barbosa Ferreira

Rio de Janeiro - RJ - Brasil

RE: Integração NetExpress 3.1 com MS Word

$
0
0

Presado Antonio,

Eu ja tinha uma classe ajWrdWord dispolinilizada por voce, acho que nos exemplos e utilities aqui do suporte. Lembra dela?

RE: Assinar XML (sign XML)

$
0
0

Prezado Renato,

Estou com o mesmo problema e também não consegui nenhuma solução pelo NetExpress 3.1. Então peguei um exemplo do ACBr  em delphi e estou desenvolvendo um programa que Valida, Assina e trasmite no meu caso de Notas Fiscais. Meu sistema gera os xmls das notas e o programa em delphi cuida do restante.

No NetExpress 3.1 não encontrei solução.

Fiz um curso del OO cobol com o Alexandre Cortez(Ciasoft). Ele tinha um site(netalexpress.blogspot.com), mas a muito tempo ele não posta nada. Ele trabalhava com NetExpress 3.1 e estava desenvolvendo os XMLS de notas fiscais.

Não sei se resolveria o seu caso.

Atenciosamente,

Rogerio  Barbosa Ferreira

RE: Integração NetExpress 3.1 com MS Word

$
0
0

Olá Rogério.

Cara, eu não me lembrava disso.

Esse programa é procedural, depois que eu conheci a tal da OOP, eu não me vicie.

Eu comecei a construir essa classe, o problema é que agora eu não desenvolvo mais profissionalmente (agora trabalho como prestação de conta em um prefeitura), então, faço isso em horas vagas.

Eu procurei na internet por "word api inserir imagem vba" e de cara encontrei isto aqui: https://goo.gl/qVW4rp

Sub InserirImagem()

   Selection.InlineShapes.AddPicture "d:\image.png"

End Sub

Vi que a inserção é feita no objeto InLineShapes, que é obtido em Selection.

Então testei pegando o "Selection" da "Application" e PIMBÁ!.

Eu ainda não sei como inserir uma imagem em uma determinada posição, este método insere na posição atual do cursor.

Copie este método na classe que te passei.

      *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*

     *                                                                 *

     *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*

      Method-id. "AddPicture".

     *------------------------------

      Local-storage          Section.

     *------------------------------

      77           InlineShapes        Object Reference.

      77           WrdPic              Object Reference.

     *------------------------------

      Linkage                Section.

     *------------------------------

      77           lnkLineShape        Object Reference.

      77           lnkLinkToFile       PIC S9(009) COMP-5. *> [IN][OPTIONAL]

      77           lnkSaveWithDocument PIC S9(009) COMP-5. *> [IN][OPTIONAL]

      77           lnkRange-CBL        PIC S9(009) COMP-5. *> [IN][OPTIONAL]

      77           lnkFileName         PIC  X(256).

     *******************************************************************

      Procedure              Division  Using lnkFileName

                                             lnkLinkToFile

                                             lnkSaveWithDocument

                                             lnkRange-CBL

                                   Returning lnkLineShape.

     *******************************************************************

       *> Pega o objeto Selection da Application

          Invoke   wordServer "getSelection" Returning theSelection

       *> Pega o objeto InlineShapes da Selection

          Invoke  theSelection "getInlineShapes" Returning InlineShapes

       *> Adicionar a imagem e retornar um objeto InlineShape

          Invoke   InlineShapes "AddPicture" Using lnkFileName

                                         Returning WrdPic

          If       Address of lnkLineShape is not equal null

                   set lnkLineShape    to WrdPic

          End-If

          Exit     Method

          .

      End method "AddPicture".

Para usar o método:

          Invoke   WRDAPP "AddPicture" Using z"C:\Fotos\FotoDoJuca.jpg"

                                                            Returning umaImagem

WRDAPP é uma instância da classe CBLWRDAPI.

"umaImagem" é uma "Object Reference" para você a utilizar, caso você queira redimensionar a imagem.

Like this:

          Invoke   umObjeto "setScaleHeight" Using By Value 50

          Invoke   umObjeto "setScaleWidth"  Using By Value 30

Ou:

          Invoke   umObjeto "setHeight" Using By Value 50

          Invoke   umObjeto "setWidth"  Using By Value 30

O jeito é buscar na web por exemplos, de preferência em VB.

Outro macete é executar no word a ação que desejar gravando-a em um macro, depois é editar a macro para ter uma ideia de como a coisa acontece.

Viewing all 375 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>