DDE and VBA

R

Rene

Hi,
I am trying to paste screens from bloomberg into textboxes
in vba so that I can then parse it. But I keep getting
this error in MS VB that says "Automation error", "The
object invoked has disconnected from its clients."

Below is the particular code that is causing the error.
It is strange because if I seperate the Textbox1.paste
into a different button and click that manually no error
shows up, but if I put all this code together, or include
code that calls the click function automatically, I get
the error. Also, when I manual paste it into the text box
with ctrl-v it works fine. Does anyone know what the
problem might be and how to get around it?

Thanks!
Rene


Sub CommandButton5_Click()
'test button

Worksheets("Main").Cells(20, 2).Copy

Dim ch As Long

ch = DDEInitiate("winblp", "bbk")
Call DDEExecute(ch, "<blp-1><home>ID <PASTE><GO><COPY>")
Call DDETerminate(ch)

TextBox1.Paste

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top