Click here to Skip to main content
15,905,420 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I'm very aware of how to use an activeX control's properties in HTML. But how do you access the methods of an activeX in HTML? I've tried google, ehow, stack overflow, and other sites. Nothing worked. My custom C++ ActiveX embeds in the webpage perfectly, but it's useless unless I can use the methods. BTW - What is the difference between methods and properties? they are the same except methods are better because they can have more than one stupid parameter in the syntax. (AFAIK)

1 solution

You just use the dot operator - the same as you do in vb.
Take this sample for example:
var excelApp=null, excelFile=null, excelSheet=null;

function initExcel(filename)
  excelApp = new ActiveXObject("Excel.Application");
  excelFile = excelApp.Workbooks.Open(filename);
  excelSheet = excelApp.Worksheets('Sheet1');

As for methods/properties - they're quite simply what their names imply - properties hold information about the object, methods are things that the object can do (functions).

WorkBooks is a property, Open is a method of that property.
Worksheets is another property of excelApp.

Properties can be simple types, like int, char, byte etc - or they can be objects with several properties/methods.

But in short - property=data, method=function. :)
Share this answer
time-killer-games 23-Aug-12 19:40pm    
For the strangest reason, I feel that I've already tried that. I'll give it another go once I get home.
time-killer-games 31-Aug-12 13:42pm    
//Does this require a specific way to write my OCX plugin? I tried that and it didn't work.
//Here's all I have in my code, apart from what is automatically generated by the ActiveX OCX project templet:

HANDLE handle;
HWND apphwnd;

int CALLBACK EnumWindowsProc(HWND hwnd, LPARAM param)
DWORD TpID = GetWindowThreadProcessId(hwnd, &pID);
if (TpID == (DWORD)param)
return false;
return true;

HANDLE StartProcess(LPCTSTR program, LPCTSTR args)

HANDLE hProcess = NULL;
STARTUPINFO startupInfo;
::ZeroMemory(&startupInfo, sizeof(startupInfo));
startupInfo.cb = sizeof(startupInfo);
if(::CreateProcess(program, (LPTSTR)args,
::EnumWindows(&EnumWindowsProc, processInfo.dwThreadId);
hProcess = processInfo.hProcess;
return hProcess;

void HostExe(LPCTSTR Exe)
CRect rect;
SetWindowLong(apphwnd, GWL_STYLE, WS_VISIBLE);
::MoveWindow(apphwnd, rect.left,,rect.right, rect.bottom, true);


void CHostExe2Ctrl::HostingStartEmbed(LPCTSTR Exe)

void CHostExe2Ctrl::HostingEndEmbed()

void CHostExe2Ctrl::HostingSetRectangle(long Left, long Top, long Right, long Bottom)

void CHostExe2Ctrl::HostingSetParent(LPCTSTR Parent)

void CHostExe2Ctrl::HostingSetChild(LPCTSTR Child)

//I added the methods with the class wizard. Is there anything else I need to add to access these methods from IE?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900