python Excel DDE input and translating it into Python

221 views Asked by At

I am using "dde" package in Python and my Excel input is

=XXExcecute|'some_code_for_financial_products'!'field_name'

As you can see it has parenthesis around strings. However, the problem is that I don't know how to "translate" the input to dde module's function inputs.

I know that inside "Create", I should type in the "XXExecute" part but don't know what to pass in ConnectTo, given the Excel input is what I mentioned above. and this function is where my code failed, giving me this messages:

c.ConnectTo("'P10102'","'9001'")
dde.error: ConnectTo failed

the entire code is as follows:

import win32ui
import dde
import pandas as pd


#making an instance
server = dde.CreateServer()

#executing instance
server.Create("XXExecute")

#DDEconversation
c= dde.CreateConversation(server)
c.ConnectTo('X10102','')
#or I tried to pass in ('X10102','9001') but it failed as well. 
c.Connected()
c.Request("9001")
0

There are 0 answers