Thread: DDE and VBA
View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Rene[_2_] Rene[_2_] is offline
external usenet poster
 
Posts: 1
Default DDE and VBA

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<homeID <PASTE<GO<COPY")
Call DDETerminate(ch)

TextBox1.Paste

End Sub