function formatEscapCaracters(f) {
return f.toString().
replace(/^[^\/]+\/\*!?/, '').
replace(/\*\/[^\/]+$/, '');
}
irpa_core.core.log('custom script close any opened Excel', irpa_core.enums.logType.Info, 'excelAutomation');
try {
var MSScrCtrl = irpa_core.activeX.create("MSScriptControl.ScriptControl");
MSScrCtrl.AllowUI = 1;
MSScrCtrl.Language = 'VBScript';
var VBScode = formatEscapCaracters(function () {/*!
Sub closeAnyOpenedExcel()
For Each Process In GetObject("winmgmts:").ExecQuery("Select Name from Win32_Process Where Name = 'EXCEL.EXE'")
Process.Terminate
Next
End Sub
*/});
MSScrCtrl.AddCode(VBScode);
MSScrCtrl.Run("closeAnyOpenedExcel");
irpa_core.core.log('custom script close any opened Excel', irpa_core.enums.logType.Info, 'excelAutomation');
} catch (error) {
irpa_core.core.log('closeAnyOpenedExcel Exception occured:' + error, irpa_core.enums.logType.Error, 'excelAutomation');
}
function formatEscapCaracters(f) {
return f.toString().
replace(/^[^\/]+\/\*!?/, '').
replace(/\*\/[^\/]+$/, '').
replace('ipSapExportFilePath', ipSapExportFilePath).
replace('ipSapExportFilePath', ipSapExportFilePath).
replace('ipSapExportFilePath', ipSapExportFilePath).
replace('ipSapExportFileName', ipSapExportFileName).
replace(/\\\\/, '\\').
replace(/\\\\/, '\\');
}
irpa_core.core.log('custom script execute Macro', irpa_core.enums.logType.Info, 'excelAutomation');
try {
var MSScrCtrl = irpa_core.activeX.create("MSScriptControl.ScriptControl");
MSScrCtrl.AllowUI = 1;
MSScrCtrl.Language = 'VBScript';
var VBScode = formatEscapCaracters(function () {/*!
Sub executeMacro()
Set objExcel = CreateObject("Excel.Application")
Set objWorkbook = objExcel.Workbooks.Open("ipSapExportFilePath\ipSapExportFileName")
objWorkbook.VBProject.VBComponents.Import "ipSapExportFilePath\ExcelMarcosModule.bas"
objExcel.Run "TheNameOfYourMacro"
objExcel.ActiveWorkbook.Save
objExcel.ActiveWorkbook.Close
objExcel.Quit
End Sub
*/});
MSScrCtrl.AddCode(VBScode);
MSScrCtrl.Run("executeMacro");
irpa_core.core.log('end custom script execute Macro', irpa_core.enums.logType.Info, 'excelAutomation');
} catch (error) {
irpa_core.core.log('executeMacro Exception occured:' + error, irpa_core.enums.logType.Error, 'excelAutomation');
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
9 | |
8 | |
5 | |
5 | |
4 | |
4 | |
4 | |
3 | |
3 | |
3 |