IMPORTANT NOTICE:  As of 21 February, anything posted in this community WILL NOT BE MIGRATED to our new community site.   We have pulled all user information and data from this site and are now in an approximately week long process of importing users, roles, and data to our new site.  We are leaving this site open and active so you can post and hopefully get a response until the migration is complete.   Once complete, the URL  that currently takes you to this site will take you to our new site so your bookmarks will work as always.  Please read the information on a New Login Process

  • State Not Answered
  • Date
  • Date 25 Jan 2019 19:57
  • Replies 2 replies
  • Subscribers 501 subscribers
  • Views 119 views
Product Documentation

saving excel workbook to specified file

We usually allow the user to specify the location to save an excel sheet produced from our system. I now want to save the sheet to a specified location/file and exit without a save dialogue box coming up. but cannot seem to get the syntax correct. Can anyone help with this?

  • Hi. I probably won't be able to help, but those who could will need to know more information:
    - how are you creating the excel spreadsheet?
    - Are you writing one out directly from cobol?
    - Are you using the ole interface somehow?
    - Are you making calls to the excel dll? (that one would be my guess)
    - how are you currently trying to save the file
  • Try something like this. The displayalerts option to zero suppresses the saveas dialog.

    77 OLEXCEL handle of application of excel.

    CREATE Application OF Excel
    HANDLE IN OLEXCEL.
    *This is for training purposes only. If you don't want to see
    *Excel, remove this line.
    MODIFY OLEXCEL @Visible = 0.
    MODIFY OLEXCEL @UserControl = 0.

    MODIFY OLEXCEL @DisplayAlerts = 0.
    EVALUATE TXT2XLS-FORMAAT
    WHEN "TXT"
    MODIFY OLEXCEL
    ActiveWorkbook::SaveAs(
    BY NAME Filename TXT2XLS-SAVEAS-BESTNAAM,
    BY NAME FileFormat xlText)
    WHEN OTHER
    MODIFY OLEXCEL
    ActiveWorkbook::SaveAs(
    BY NAME Filename TXT2XLS-SAVEAS-BESTNAAM,
    BY NAME FileFormat xlNormal)
    END-EVALUATE.