Highlighted
Absent Member.
Absent Member.
1906 views

Calling Winword

Jump to solution

For displaying reports my acucobol programs call winword through the C$SYSTEM.  ie,

05   winword-location  pic x(60) value "c:\progra~1\micros~1\root\office15\winword.exe "

CALL "C$SYSTEM" USING winword-location report-name.txt  giving exit-status

Is there a better way for displaying reports instead of using command prompt to call Word? 

The program which calls Word maintains a hardcoded list of locations for WinWord.exe and if its not found, the program calls NotePad.  Got two problems - 1) WinWord always moves location when new o/s comes out, so it'd be nice if there was an easy way that always worked for locating WinWord.  2) The latest version of Word is 64 bit and having problems calling it from 32bit environment. 

Thanks alot 

0 Likes
2 Solutions

Accepted Solutions
Highlighted
Absent Member.
Absent Member.

RE: Calling Winword

Jump to solution

One way would be to call Explorer with C$SYSTEM. For example:

CALL "C$SYSTEM" USING "Explorer report-name.txt" giving exit-status.

This will open the default program for a .txt file. You can use this for any type of Windows action even to send mail likes this:

CALL "C$SYSTEM" USING "Explorer mailto:test@testcompani.org"

It also works in a thin client environment - you simple add @[DISPLAY]: in front of the argument eg.:

CALL "C$SYSTEM" USING "@DISPLAY]:explorer report-name.txt" giving exit-status.

View solution in original post

0 Likes
Highlighted
Honored Contributor.
Honored Contributor.

RE: Calling Winword

Jump to solution

use registry to read where winword is installed.

      78  wo-path value "Software\Microsoft\Windows\CurrentVersion\App

     -                  "Paths\Winword.exe".

       78  reg-null               value x"00".
       77  reg-handle                            usage is unsigned-long.
       77  reg-size                              usage is unsigned-long.
       77  reg-code               pic s9(4).
       77  reg-path               pic x(255)     value spaces.

      ***********************************************************
       word-handle section.
      ***  check registry
           move    wo-path to reg-path
           perform registry-handle.

           if reg-path = spaces
              move 6 to fKomm-Err
              go to  word-handle-ende.

      ***  call parameter
           if fKomm-Url = spaces
              move 4 to fKomm-Err
              go to  word-handle-ende.

           inspect fKomm-Url replacing trailing spaces by "¿".

      ***  Word mit Dokument starten
           string reg-path(1:reg-size - 1) " "
                  "/q /f " fKomm-Url
                  delimited by "¿" into fk-run.

           call   "c$run" using fk-run.

       word-handle-ende.
           exit.
       word-handle-e.
      ***********************************************************

       registry-handle section.
      ***  key öffnen
           call "REG_OPEN_KEY" using  HKEY_LOCAL_MACHINE,
                                      reg-path,
                                      reg-handle,
                               giving reg-code.

           move spaces to reg-path.

           if reg-code not = zeroes
              go to registry-handle-finish.

      ***  entry lesen
           call "REG_QUERY_VALUE_EX" using  reg-handle,
                                            " "
                                            "REG_SZ",
                                            reg-path,
                                            reg-size,
                                     giving reg-code.

           if reg-code not = zeroes
              move spaces to reg-path.

       registry-handle-finish.
      ***  close key
           call "REG_CLOSE_KEY" using reg-handle.

       registry-handle-ende.
           exit.
       registry-handle-e.
      ***********************************************************

It's only a example from a programm we use...

View solution in original post

0 Likes
3 Replies
Highlighted
Absent Member.
Absent Member.

RE: Calling Winword

Jump to solution

One way would be to call Explorer with C$SYSTEM. For example:

CALL "C$SYSTEM" USING "Explorer report-name.txt" giving exit-status.

This will open the default program for a .txt file. You can use this for any type of Windows action even to send mail likes this:

CALL "C$SYSTEM" USING "Explorer mailto:test@testcompani.org"

It also works in a thin client environment - you simple add @[DISPLAY]: in front of the argument eg.:

CALL "C$SYSTEM" USING "@DISPLAY]:explorer report-name.txt" giving exit-status.

View solution in original post

0 Likes
Highlighted
Honored Contributor.
Honored Contributor.

RE: Calling Winword

Jump to solution

use registry to read where winword is installed.

      78  wo-path value "Software\Microsoft\Windows\CurrentVersion\App

     -                  "Paths\Winword.exe".

       78  reg-null               value x"00".
       77  reg-handle                            usage is unsigned-long.
       77  reg-size                              usage is unsigned-long.
       77  reg-code               pic s9(4).
       77  reg-path               pic x(255)     value spaces.

      ***********************************************************
       word-handle section.
      ***  check registry
           move    wo-path to reg-path
           perform registry-handle.

           if reg-path = spaces
              move 6 to fKomm-Err
              go to  word-handle-ende.

      ***  call parameter
           if fKomm-Url = spaces
              move 4 to fKomm-Err
              go to  word-handle-ende.

           inspect fKomm-Url replacing trailing spaces by "¿".

      ***  Word mit Dokument starten
           string reg-path(1:reg-size - 1) " "
                  "/q /f " fKomm-Url
                  delimited by "¿" into fk-run.

           call   "c$run" using fk-run.

       word-handle-ende.
           exit.
       word-handle-e.
      ***********************************************************

       registry-handle section.
      ***  key öffnen
           call "REG_OPEN_KEY" using  HKEY_LOCAL_MACHINE,
                                      reg-path,
                                      reg-handle,
                               giving reg-code.

           move spaces to reg-path.

           if reg-code not = zeroes
              go to registry-handle-finish.

      ***  entry lesen
           call "REG_QUERY_VALUE_EX" using  reg-handle,
                                            " "
                                            "REG_SZ",
                                            reg-path,
                                            reg-size,
                                     giving reg-code.

           if reg-code not = zeroes
              move spaces to reg-path.

       registry-handle-finish.
      ***  close key
           call "REG_CLOSE_KEY" using reg-handle.

       registry-handle-ende.
           exit.
       registry-handle-e.
      ***********************************************************

It's only a example from a programm we use...

View solution in original post

0 Likes
Highlighted
Absent Member.
Absent Member.

RE: Calling Winword

Jump to solution

Thank you for your excellent suggestions.  I like the added info about emailing, too.

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.