Author Topic: Opening Desired Excel file with Pushbutton  (Read 7262 times)

Ashfaq Ahmed

  • Administrator
  • Newbie
  • *****
  • Posts: 32
    • View Profile
Opening Desired Excel file with Pushbutton
« on: October 29, 2020, 03:08:50 AM »
Purpose:
To Open the Excel File with a Click of Pushbutton.
-It is helpful in opening the Desired Excel file from within the SAP Screen.

Pre-requisites:
Liquid UI WS
Microsoft Excel

Note:
"wsoffice.dll" file must be present in the Script Directory and it should be Loaded in "ESESSION.SJS" File

Eg:
////ESESSION.sjs////
load("wsoffice");

Example:
Please follow the below Steps:

Step-1: Open the Easy Access Script file "SAPLSMTR_NAVIGATION.E0100.sjs" which can be found in the directory folder as Configured in the "guixt.sjs" file.

//Add the Below LIQUID UI Code to the file

/////////////////////////////SAPLSMTR_NAVIGATION.E0100.SJS/////////////////////////////

// Function to Select the Excel File
function SelectExcelfile(param){                                       
    if(szPrompt==void 0) szPrompt = 'Select the Excel File';
    var dialog = new ActiveXObject('MsComDlg.CommonDialog'); 
    dialog.Filter='Excel Files(*.xlsx*)|*.xlsx*'; 
    dialog.MaxFileSize=32767; 
    dialog.DialogTitle=szPrompt;
    dialog.Flags=0x200|0x80000|0x800|0x4|0x200000;
    dialog.ShowOpen(); 
    var file = dialog.FileName;
    dialog = void 0;
    if(file!=""){
        openExcelfile(file);
    }
    else{
       message("File Not Selected!",{"StatusLine":true,"title":"Information","type":"W"});
    }

}

// Function to Open the Excel File
function openExcelfile(filename){
g_ExcelApp = new ActiveXObject('Excel.Application');
g_ExcelBook=g_ExcelApp.Workbooks.Open(filename);
g_ExcelApp.Visible=true;
g_ExcelApp.ScreenUpdating=true;
message("S: "+filename+" Excel File is Opened Successfully");
}

// Screen Script
pushbutton([TOOLBAR], "@48@Open Excel File",{ "process":SelectExcelfile});


Step-2: Save the File and Refresh the SAP Screen.

Step-3: Click on the "Open Excel file" TOOLBAR Pushbutton.

Step-4: It will bring up the Pop-up Window, Select the Excel file that need's to be open.

Step-5: It will display a Success Message and will open the Selected Excel File.


Refer to the Attachment for Further Reference......