com package¶
win32com.client¶
This module exists to create the “best” dispatch object for a given object. If “makepy” support for a given object is detected, it is used, otherwise a dynamic dispatch object.
Note that if the unknown dispatch object then returns a known dispatch object, the known class will be used. This contrasts with dynamic.Dispatch behaviour, where dynamic objects are always used.
- win32com.client.Dispatch(dispatch, userName=None, resultCLSID=None, typeinfo=None, UnicodeToString=None, clsctx=pythoncom.CLSCTX_SERVER)¶
- Parameters:
dispatch (str) – A dispatch object
userName (str, optional) – User name
resultCLSID (str, optional) – Class ID
typeinfo (str, optional) – Type information param
UnicodeToString (bool, optional) –
Deprecated since version 305: Use None or leave blank.
clsctx (int) – Execution contexts in which a class object is to be run, defaults to
pythoncom.CLSCTX_SERVER
- Returns:
__WrapDispatch()
- Return type:
Callable
Creates a Dispatch-based COM object.
>>> import win32com.client >>> xl_app = win32com.client.Dispatch("Excel.Application")
win32com.client.__WrapDispatch is a helper function that returns a makepy-generated class for a CLSID if it exists, otherwise cope by using CDispatch.
See also
win32com.client.build¶
win32com.clientCLSIDToClass¶
win32com.client.combrowse¶
win32com.client.connect¶
win32com.client.dynamic¶
Dynamic COM client support is the ability to use a COM server without prior knowledge of the server. This can be used to talk to almost all COM servers, including much of Microsoft Office.
In general, you should not use this module directly.
Example:
>>> import win32com.client
>>> xl_app = win32com.client.Dispatch("Excel.Application")
>>> xl_app.Visible = 1 # The Excel window becomes visible.
The line above invokes the functionality of this class. Now we can use xl_app
to talk to Excel.
- win32com.client.Dispatch(dispatch, userName=None, createClass=None, typeinfo=None, UnicodeToString=None, clsctx=pythoncom.CLSCTX_SERVER)¶
- Parameters:
dispatch (str) – A dispatch object
userName (str, optional) – User name
createClass – Class ID?
typeinfo (str, optional) – Type information param
UnicodeToString (bool, optional) –
Deprecated since version 305: Use None or leave blank.
clsctx (int) – Class context, defaults to
pythoncom.CLSCTX_SERVER
- Returns:
createClass()
- Return type:
Callable
Creates a dynamic Dispatch-based COM object.
See also