Skip to main content

[archive] Opening pdf, word, excel ...etc from Cobol

  • June 7, 2008
  • 7 replies
  • 0 views

[Migrated content. Thread originally posted on 07 June 2008]

I use C$SYSTEM to open the file. Sometimes I need to put "start" in front of it. For example: start c:\\mypath\\mydoc.doc. Since .doc is associated with Word, then Word will open the file.

7 replies

[Migrated content. Thread originally posted on 07 June 2008]

I use C$SYSTEM to open the file. Sometimes I need to put "start" in front of it. For example: start c:\\mypath\\mydoc.doc. Since .doc is associated with Word, then Word will open the file.
Hello,

I'm using the web-browser to open any external file from within the cobol program.
The pdf opens in a very nice way under the web-browser and allowing me to print but:

1. MS-Office files word, excel etc open but it doesn't allow me to print, just to display the contents of the file.
2. Open Office(open source office) is opening completely in a new window.

Does anyone want to exchange ideas about this.

Regards,

[Migrated content. Thread originally posted on 07 June 2008]

I use C$SYSTEM to open the file. Sometimes I need to put "start" in front of it. For example: start c:\\mypath\\mydoc.doc. Since .doc is associated with Word, then Word will open the file.
If you want to open and print Word and/or Excel files, your most solid approach is to use COM. Should be some examples around in the forum.
Open Office does have a COM interface, but it is late binding and Acu does not work with that.
An alternative may be to execute:
c:\\OfficeRoot\\WinWord.exe /p mydoc.doc
Or, you can use the Shell COM object.

[Migrated content. Thread originally posted on 07 June 2008]

I use C$SYSTEM to open the file. Sometimes I need to put "start" in front of it. For example: start c:\\mypath\\mydoc.doc. Since .doc is associated with Word, then Word will open the file.
Thanks for responding to my post.

Starting from the second comment to use a batch file, I've tried this way before, it does work but it takes a long time until it loads the application and to open the file, and poeple are not have patient to wait, moreover they think the application is crashed.

About using COM (Common Object Module) in other words Active-X, the browser does this automatically, I mean when I open any file using the web-browser it creates a COM for this file and it displays it.

The most efficent one is the PDF files, but when we comes to Micorsoft the situation is different, not printing.

Regards,

[Migrated content. Thread originally posted on 07 June 2008]

I use C$SYSTEM to open the file. Sometimes I need to put "start" in front of it. For example: start c:\\mypath\\mydoc.doc. Since .doc is associated with Word, then Word will open the file.
Provided you have created the msword.def, this should do your printing, without having to use shell.


       IDENTIFICATION               DIVISION.
       PROGRAM-ID.                  HelloWorld.
       SPECIAL-NAMES.
           COPY "MSWORD.DEF".
                          .
       WORKING-STORAGE SECTION.
       01  HANDLES.
           03  wrdApp               HANDLE OF APPLICATION.
           03  wrdDoc               HANDLE OF DOCUMENT.
       PROCEDURE DIVISION.
       APP-MAIN    SECTION.
       APP-MAIN-001.
      *Create the Word OLE object and instantiate a connection to it.
           CREATE  APPLICATION      OF WORD
                   HANDLE           IN wrdApp.
      *Show Word, this is very handy when debugging, as you will see
      *everything as it happens. In production you would probably not
      *set it visible. Word is by default hidden when invoked through
      *OLE.
           MODIFY  wrdApp           @Visible = 1.
           MODIFY  wrdApp           Documents::Open("c:\\Mydoc.doc")
                   GIVING           wrdDoc.
           MODIFY  wrdDoc           @PrintOut().
           DESTROY wrdDoc.
    MODIFY  wrdApp           Quit().
    DESTROY wrdApp.
       APP-MAIN-900.
           STOP    RUN.
       APP-MAIN-EXIT.
           EXIT.

Substituting PrintOut with PrintView and you get...

[Migrated content. Thread originally posted on 07 June 2008]

I use C$SYSTEM to open the file. Sometimes I need to put "start" in front of it. For example: start c:\\mypath\\mydoc.doc. Since .doc is associated with Word, then Word will open the file.
I didn't use the OLE before, where can I get "MSWORD.def" file, or this is something I create myself?

Regards

[Migrated content. Thread originally posted on 07 June 2008]

I use C$SYSTEM to open the file. Sometimes I need to put "start" in front of it. For example: start c:\\mypath\\mydoc.doc. Since .doc is associated with Word, then Word will open the file.
Use axdefgen.exe, which can be found in the installation path under acugt\\bin most likely. I have done it this way or I think if you pull it in as an active-x on a screen, when you generate, it will automatically creat the .def file in your copylib path too.

best of luck, Mike

[Migrated content. Thread originally posted on 07 June 2008]

I use C$SYSTEM to open the file. Sometimes I need to put "start" in front of it. For example: start c:\\mypath\\mydoc.doc. Since .doc is associated with Word, then Word will open the file.
Thanks

Regards