ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   DDE and VBA (https://www.excelbanter.com/excel-programming/282207-dde-vba.html)

Rene[_2_]

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


All times are GMT +1. The time now is 05:43 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com