473,508 Members | 2,428 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

MS COM early and late binding

Is there a way to find out if I am using early or late binding given
the reference ("excel" in the example below) returned by Dispatch()?
import win32com.client
excel = win32com.client.Dispatch('Excel.Application')


Thanks much for your help.

Olaf
Jul 18 '05 #1
4 3491
Ol********@compuserve.com (Olaf Meding) writes:
Is there a way to find out if I am using early or late binding given
the reference ("excel" in the example below) returned by Dispatch()?
import win32com.client
excel = win32com.client.Dispatch('Excel.Application')


try:
excel.visible
except AttributeError:
print "late bound"
else:
print "early bound"

Hint: Attributes are case sensitive when early bound ;-)

Thomas
Jul 18 '05 #2
Thomas

What you suggest might work, but does not look to elegant. Can anyone else
perhaps suggest a more elegant solution? Thanks.

Olaf
try:
excel.visible
except AttributeError:
print "late bound"
else:
print "early bound"

Hint: Attributes are case sensitive when early bound ;-)

Jul 18 '05 #3
Olaf Meding wrote:
Is there a way to find out if I am using early or late binding given
the reference ("excel" in the example below) returned by Dispatch()?

import win32com.client
excel = win32com.client.Dispatch('Excel.Application')


There is no great way to find out (other than looking at the repr() of
the object or trying Thomas's trick), but there is a way to force one or
the other.

excel = win32com.client.gencache.EnsureDispatch(excel)

Will ensure you have early bound, executing makepy if necessary.

excel = win32com.client.dynamic.DumbDispatch(excel)

Will force late bound, even if the object is currently early.

Mark.
Jul 18 '05 #4
"Olaf Meding" <Ol********@noSpam.compuserve.com> wrote in message news:<40**********@newspeer2.tds.net>...
What you suggest might work, but does not look to elegant. Can anyone else
perhaps suggest a more elegant solution? Thanks.


Not elegant? This is COM, you know!

Anyway, I do this:

excel = win32com.client.gencache.EnsureDispatch('Excel.App lication')

Then I know I'm using early binding.

Cheers,
Simon B.
Jul 18 '05 #5

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

Similar topics

8
3841
by: deko | last post by:
When using automation (and especially with early binding) I've heard it is best to use explicit references to everything. For example: Dim xlChart as Excel.Chart rather than Dim objChart...
2
6631
by: Mystery Man | last post by:
We are developing a C# application that has many interfaces to the Microsoft suite (eg Word, Excel, Outlook, Powerpoint, etc). We need to support Office 97, 2000, 2002 and any future versions. ...
5
1861
by: Plat | last post by:
Summary: I've got some *.ASPX pages that still use COM objects. I'd like to enable Option Strict, but I get "error BC30574: Option Strict On disallows late binding" errors. How can I bypass this...
2
1715
by: mark | last post by:
I understand that writing programs with option strict on is the best way to obtain stable applications. I have also found the applications to run much faster. Option strict on disallows late...
21
3053
by: ManningFan | last post by:
I need to use late binding in a project because it's company standard to not include references which aren't MS defaults, so I can't add the scripting runtime. I need to be able to search...
2
3684
by: kogrover | last post by:
ISSUE: COM Excel Sort works with Early Binding, but not Late Binding, but py2exe only does Late Binding I have code similar to this (type from notes, so there may be a typo...) import...
3
16043
ADezii
by: ADezii | last post by:
The process of verifying that an Object exists and that a specified Property or Method is valid is called Binding. There are two times when this verification process can take place: during compile...
0
1110
by: RN1 | last post by:
Is this late binding? -------------------------------------------------------------------------------- Dim dSet As DataSet dSet = New DataSet...
1
3361
by: pedestrian via DotNetMonster.com | last post by:
What are the example of early binding? How about late binding? Thank you for replying. (: -- Warmest Regards, Pedestrian Message posted via DotNetMonster.com
0
7405
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7066
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5643
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,...
1
5059
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4724
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...
0
3214
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...
0
3198
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1568
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 ...
1
773
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.