Cloud Computing Insider Awards 2022: Vote for ONLYOFFICE
Vote for ONLYOFFICE

How to create ActiveXObject in plugin?

Hello,
I need to create an ActiveXObject in plugin.
On the statement dlg = new ActiveXObject(“NormaCS.Application.Dialogs”); an exception occurs with the text ActiveXObject is not defined.
How can this problem be solved?

Hello @boris
Please provide us with entire issue scenario. If it’s possible share your plugin and steps to reproduce an issue.

The task is this. I need to read text from uploaded file. I pass this text to the com object.
And then, using the methods and properties of this com object, I process it. But first I need to create this com object.
The plugin looks something like this:

// Call NormaCS dialog
(function(window, undefined){
    
	try {    
		var text = "Hello world!";	// test variant
		var dlg = null;
		var find = null;

		//console.log("1");
		dlg = new ActiveXObject("NormaCS.Application.Dialogs");
		//console.log("2");
		window.Asc.plugin.init = function()
		{
					// call command with external variables
					Asc.scope.text = text; // export variable to plugin scope
					this.callCommand(function() {
						//console.log("3");
						find = dlg.Find;
						find.Text = Asc.scope.text;
						find.Show();
					}, true);
		};

		window.Asc.plugin.button = function(id)
		{
		};
	}
	catch (e) {
		console.log(e.message);
	}

})(window, undefined);

Probably you should take a look at this plugin as an example: ONLYOFFICE Api Documentation - Plugin examples
It contains OleObject.

If I understand correctly, the AddOleObject method ONLYOFFICE Api Documentation - executeMethod only applies to JSON objects. My object is based on C++, so this method does not apply to it.

As far as I understand ActiveXObject is outdated mechanism for Internet Explorer browser:

I assume that you have tried to run your plugin not in Internet Explorer. If you still want to use ActiveXObject probably it’s better to look for alternative since Internet Explorer is no longer supported.

Why Internet Explorer? I am debugging a plugin in OnlyOffice.

ActiveXObject is the element which works in Internet Explorer only. That browser isn’t supported anymore.
So when you try to use this element, you face an issue, because this element works in Internet Explorer only.