Usage of ActiveX objects in Script Components

Script components allow to use ActiveX objects into the AEP greatly expanding data processing and storing capabilities.

Below is the example of saving the processing data in a Microsoft Excel document using JScript.

Global Variables

SenderName

SenderEmail

JScript Code

var wbname = "C:\\Program Files\\Advanced Email Parser\\Examples\\ActiveX\\list.xls";

var wbkey = SenderEmail.Value;

var wbdata = SenderName.Value;

 

var xl = new ActiveXObject("Excel.Application");

var wb = xl.Workbooks.Open(wbname);

var ws = wb.Worksheets(1);

var item = ws.Columns(1).Find(wbkey);

if(item)

{

  item.Cells(1, 2) = wbdata;

}

else

{

  var cnt = ws.Rows.Count;

  var idx = 1;

  while(idx < cnt)

  {

    if(ws.Cells(idx, 1).Value == null) break;

    idx++;

  }

  ws.Cells(idx, 1) = wbkey;

  ws.Cells(idx, 2) = wbdata;

}

wb.Close(true);

See also

Information for Programmers

Script Components

© 2020 Mediatwins s.r.o. All rights reserved.