Why are some COM methods missing?

7 次查看(过去 30 天)
M Koelemay
M Koelemay 2013-1-24
I am using the Python package "comtypes" to open a Matlab COM Automation Server from Python. It seemed to be working just fine, as with the code below I was able to make a Matlab COM object, and set a string to the Matlab workspace.
from comtypes.client import CreateObject
m=CreateObject('Matlab.Desktop.Application')
m.PutCharArray('mystr','base','hello world')
The problem is that it does not let me call "execute" and does not even show "execute" as an available method for that COM object. Here is what it shows me for available methods:
| Feval = func(obj, *args, **kw)
|
| GetCharArray = func(obj, *args, **kw)
|
| GetVariable = func(obj, *args, **kw)
|
| GetWorkspaceData = func(obj, *args, **kw)
|
| MaximizeCommandWindow = func(obj, *args, **kw)
|
| PutCharArray = func(obj, *args, **kw)
|
| PutWorkspaceData = func(obj, *args, **kw)
|
| Quit = func(obj, *args, **kw)
|
| XLEval = func(obj, *args, **kw)
|
| ----------------------------------------------------------------------
| Data descriptors inherited from comtypes.gen._C36E46AB_6A81_457B_9F91_A7719A06287F_0_1_0.DIMLApp:
|
| Visible
I am confused as to why Execute would not be an available call from this COM object; any help would be greatly appreciated.

回答(1 个)

Amro
Amro 2013-5-20
This works for me:
import win32com.client
m = win32com.client.Dispatch('matlab.application')
m.Execute("plot(rand(100,1))")
m.Quit()

类别

Help CenterFile Exchange 中查找有关 Data Import and Export 的更多信息

产品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by