1

In Visual studio there is an option to register as an Interop COM. I want to achieve the same using python language. If someone can help me how to go about this. I did my research but couldnt find anything.

2
  • Did you find docs.activestate.com/activepython/2.7/pywin32/com_overview.html Commented Sep 20, 2013 at 6:46
  • Although it seems like not a good SO question, but people seeking the answer to this question will definitely being brought to this page. An up vote from me! Commented Mar 31, 2014 at 6:26

2 Answers 2

1

Like my namesake comments above. Use the pywin32 module. Alternatively you can use the comtypes module instead. Because python is a interpreted language you can use COM in 2 separate ways. By generating a interoperability layer or by dynamic typing. Both comtypes and pywin32, can do dynamic typing. Additionally pywin32's win32com module can also generate a interoperability layer, this has a drawback tough as dynamic typing is often easier to handle. Here is a simple example that generates a interop like compatibility layer (if on does not exist) in excel. Then the script opens a existing worksheet and edits the first cell value:

from win32com.client.gencache import EnsureDispatch

xl = EnsureDispatch ("Excel.Application")
xl.Visible = True
wb = xl.Workbooks.Open(r'c:\temp\test.xlsx')
sht = wb.Worksheets(1)
sht.Cells(1,1).Value = "yeah this works"

PS: Stack overflow already automatically suggests a lot of resources for you to follow in the related sidebar.

Sign up to request clarification or add additional context in comments.

Comments

-1
import win32com.server.register
   win32com.server.register.UseCommandLine(ClassName)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.