473,659 Members | 2,626 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

GetObject function in windows services

Hello,

I posted yesterday the same problem, but now I want to be
more specific about it.

My intention is to create a windows service to process
some Word documents. If I use CreateObject to create a
reference to a Word object everything is working fine.

If I use GetObject to get a reference to Word object (of
course that Word applicaton is started) I get an error
("Cannot create ActiveX component")

It is like my service cannot detect that Word application
is started.

I want to say that GetObject is working fine from a
standard Windows application.

Thank you,
Andrei

Jul 21 '05 #1
5 6356
"Andrei" <pr**********@h otmail.com> wrote in news:003b01c377 0f$d95a89b0
$a*******@phx.g bl:
Hello,

I posted yesterday the same problem, but now I want to be
more specific about it.

My intention is to create a windows service to process
some Word documents. If I use CreateObject to create a
reference to a Word object everything is working fine.

If I use GetObject to get a reference to Word object (of
course that Word applicaton is started) I get an error
("Cannot create ActiveX component")

It is like my service cannot detect that Word application
is started.

I want to say that GetObject is working fine from a
standard Windows application.

Thank you,
Andrei


I'm unclear as to what is working and what is not for you? Are you
saying GetObject() works for getting the reference to the application,
but not other classes inside the application? Getobject() is only for
getting a reference to the application. You don't use it to get a
Document class instance. instead use the Documents property of the
Application instance!

Here is the code I use to get a reference to an application object in
AutoCAD. This should be very similar for a Word application:

mcadApplication = (AutoCAD.AcadAp plicationClass)
Marshal.GetActi veObject("AutoC AD.Application" );

It works similarly to GetObject.

--
Michael Lang, MCSD

Jul 21 '05 #2
Hi Michael,

Thank you for your reply. I will try to be more clear.

GetObject is returning me an error when I try to get a
reference to the Word application. But this is happening
only in windows services, in a standard windows
application I have no error.

CreateObject is working fine in both cases (windows
services or windows applications)

My question is why I cannot use GetObject in a windows
sevice?

Thank you,
Andrei

-----Original Message-----
"Andrei" <pr**********@h otmail.com> wrote in news:003b01c377 0f$d95a89b0$a*******@phx. gbl:
Hello,

I posted yesterday the same problem, but now I want to be more specific about it.

My intention is to create a windows service to process
some Word documents. If I use CreateObject to create a
reference to a Word object everything is working fine.

If I use GetObject to get a reference to Word object (of course that Word applicaton is started) I get an error
("Cannot create ActiveX component")

It is like my service cannot detect that Word application is started.

I want to say that GetObject is working fine from a
standard Windows application.

Thank you,
Andrei
I'm unclear as to what is working and what is not for

you? Are yousaying GetObject() works for getting the reference to the application,but not other classes inside the application? Getobject () is only forgetting a reference to the application. You don't use it to get aDocument class instance. instead use the Documents property of theApplication instance!

Here is the code I use to get a reference to an application object inAutoCAD. This should be very similar for a Word application:
mcadApplicatio n = (AutoCAD.AcadAp plicationClass)
Marshal.GetActi veObject("AutoC AD.Application" );

It works similarly to GetObject.

--
Michael Lang, MCSD

.

Jul 21 '05 #3
Hi Michael,

I have tried using Marshal.GetActi veObject instead of
GetObject as you suggested. I got an error : "Operation
unavailable"

Andrei,
-----Original Message-----
"Andrei" <pr**********@h otmail.com> wrote in news:003b01c377 0f$d95a89b0$a*******@phx. gbl:
Hello,

I posted yesterday the same problem, but now I want to be more specific about it.

My intention is to create a windows service to process
some Word documents. If I use CreateObject to create a
reference to a Word object everything is working fine.

If I use GetObject to get a reference to Word object (of course that Word applicaton is started) I get an error
("Cannot create ActiveX component")

It is like my service cannot detect that Word application is started.

I want to say that GetObject is working fine from a
standard Windows application.

Thank you,
Andrei
I'm unclear as to what is working and what is not for

you? Are yousaying GetObject() works for getting the reference to the application,but not other classes inside the application? Getobject () is only forgetting a reference to the application. You don't use it to get aDocument class instance. instead use the Documents property of theApplication instance!

Here is the code I use to get a reference to an application object inAutoCAD. This should be very similar for a Word application:
mcadApplicatio n = (AutoCAD.AcadAp plicationClass)
Marshal.GetActi veObject("AutoC AD.Application" );

It works similarly to GetObject.

--
Michael Lang, MCSD

.

Jul 21 '05 #4
"Andrei" <pr**********@h otmail.com> wrote in news:042b01c377 16$38e01020
$a*******@phx.g bl:
Hi Michael,

I have tried using Marshal.GetActi veObject instead of
GetObject as you suggested. I got an error : "Operation
unavailable"

Andrei,


Sorry, I've never made a Windows Service. I don't know why it would work
on Windows Forms and not a Windows Service?

--
Michael Lang, MCSD

Jul 21 '05 #5
This is the kind of thing that smells of a security issue. Your Service is
probably running with the LocalSystem account in its own Windowstation, but
trying to drive a Word application that may be installed for a different
user, or that can't access the interactive user's desktop.

What happens if you run the Service under your account name/password?
--
Phil Wilson [MVP Windows Installer]

"Andrei" <pr**********@h otmail.com> wrote in message
news:00******** *************** *****@phx.gbl.. .
Hello,

I posted yesterday the same problem, but now I want to be
more specific about it.

My intention is to create a windows service to process
some Word documents. If I use CreateObject to create a
reference to a Word object everything is working fine.

If I use GetObject to get a reference to Word object (of
course that Word applicaton is started) I get an error
("Cannot create ActiveX component")

It is like my service cannot detect that Word application
is started.

I want to say that GetObject is working fine from a
standard Windows application.

Thank you,
Andrei

Jul 21 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
4804
by: Gerry | last post by:
I have a developer here with a website running with only "Windows Integrated Authentication" set on a Windows 2000 member server that uses GetObject to get a user's group membership in the domain. This is the code she's using: set adsUser = getobject("WinNT://" & strUsername) for each group in adsUser.groups GrpList = GrpList & lcase(trim(group.name)) & ";" next
2
5997
by: CJM | last post by:
I'm building an ASP app that uses Windows Authentication (IWA). I have an authentication routine that assesses if & how the user can use the application (see code snippet below). Users of a particular group have full permissions (configured via IIS) and all other users have read/execute permissions. When I call the authentication page from the server on my own PC, everything seems to work, but I guess this is not a respresentative...
2
2240
by: Andrei Prodan | last post by:
Hi everyone, I have a small piece of code which uses GetObject function and it is working fine in a windows application developed under .NET In a windows service application, the GetObject function returns an error: "Cannot create ActiveX component" Does anyone knows why ??
4
6389
by: bic | last post by:
When porting my Windows app to asp.net I get an System.Exception: Cannot create ActiveX component. What function can I use instead? Thanks for your comments. -- bic
3
20275
by: Otie | last post by:
I found the following under the GetObject help notes and in the example for GetObject: "This example uses the GetObject function to get a reference to a specific Microsoft Excel worksheet (MyXL). It uses the worksheet's Application property to make Microsoft Excel visible, to close it, and so on. Using two API calls, the DetectExcel Sub procedure looks for Microsoft Excel, and if it is running, enters it in the Running Object Table. The...
5
6121
by: Yong Yu | last post by:
Dear All, I have to move my VB code to C#. But I have no idea on the GetObject method in Vb. ----------------------------------------- Set dom = GetObject("WinNT://" & domain) ----------------------------------------- This is easy for VB to get the object by COM monikor interface.
3
4763
by: perspolis | last post by:
Is there a method like GetObject in vb to get an instance of current object runnig??
5
526
by: Andrei | last post by:
Hello, I posted yesterday the same problem, but now I want to be more specific about it. My intention is to create a windows service to process some Word documents. If I use CreateObject to create a reference to a Word object everything is working fine. If I use GetObject to get a reference to Word object (of
3
5859
by: aydeejay | last post by:
I'm trying to troubleshoot an issue where users are not able to bind with LDAP via "GetObject" through our ASP Classic Intranet if they stay logged in overnight (beyond their allowed login hours). The problem does not occur when performing the same bindings using a logon script. So, the user logs in, is able to perform queries all day, and then fails to log out at the end of the day. We'd prefer that they did log out nightly, but it...
0
8428
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8629
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7360
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5650
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4176
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4338
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2757
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1982
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1739
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.