/    Sign up×
Community /Pin to ProfileBookmark

ActiveXObject help

Hello forum,

I am fairly inexperienced with web development and would like to make a simple label maker for my companies intranet site. The site needs to have the functionality to send a webpage to the printer using customized page settings looking into using an ActiveX component to do this.

I have followed this article on how to create an ActiveX control in C#. [url]http://dotnetslackers.com/articles/csharp/WritingAnActiveXControlInCSharp.aspx[/url]

I have placed the example HTML on our companies intranet site.

Browsing to the website on the webserver, everything works fine and is just what I am after.

If I go to another computer in the company and browse to the website in Internet Explorer, I get the following script error..

[B]Automation server can’t create object [/B]

on line

[CODE]var x = new ActiveXObject(“ANamespace.AClass”);[/CODE]

This makes sense to me because the computer doesn’t have the activex object installed.
What I was hoping is that, internet explorer would ask the user to download the ActiveX object, and run my print code.

I am not sure the direction I need to go and am looking for some advice

Thanks

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@astupidnameAug 04.2011 — The site needs to have the functionality to send a webpage to the printer using customized page settings[/quote]
I believe you may be going down the wrong path here (that's o.k. though, part of learning, right?). The only reason one could have to utilize an ActiveXObject for this task is if you would literally be needing to work with files that are actually on the client computers and not on the server. Achieving customized page settings for printing is relatively easily do-able via css and javascript in the browser. In javascript you may use things such as window.open and window.print functions and some javascript processing for the data to send to the opened window perhaps or maybe all you need is customized css in the opened window or just the current window. It's unclear what exactly you need customized about the pages to print. But perhaps you could simply get away with using css via a style tag with media="print" in it's attributes. As in:
[code=html]<style type="text/css" media="print">

.doNotPrintMe { /* a class name you would apply to things you do not wish printed */
display:none;
}

</style>
<p>A paragraph with some text that will be printed because this paragraph does not have &quot;doNotPrintMe&quot; in a class attribute for its css</p>
<button type="button" class="doNotPrintMe" onclick="window.print();" title="(This button won't be printed)">PRINT</button>[/code]
×

Success!

Help @unigee spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...