C
Candide
Hello,
I try to copy data from an external application into Excel thanks to
VBA. It seems to work for Acrobat Reader but not for Bloomberg
Terminal. When I do it by hand, it is fine. When I run the macro
below, I do get the last data I have stored to the clipboard before
running the macro i.e. the macro does not copy anything new. I tried
several time periods in Wait with no luck. Any idea?
Public Sub procGrabData()
Dim lngBlp As Long
lngBlp = DDEInitiate("winblp", "bbk")
Call DDEExecute(lngBlp, "<blp-1>")
Application.Wait (Now + TimeValue("0:00:05"))
SendKeys "^a", True
Application.Wait (Now + TimeValue("0:00:05"))
SendKeys "^c", True
Application.Wait (Now + TimeValue("0:00:05"))
AppActivate "Microsoft Excel"
ActiveSheet.PasteSpecial
Call DDETerminate(lngBlp)
End Sub
BTW, I have tried DataObject but the results are the same when I
change ActiveSheet.PasteSpecial with:
Dim objData As New DataObject
objData.GetFromClipboard
ActiveCell = objData.GetText
Thank you for your help,
Xavier
I try to copy data from an external application into Excel thanks to
VBA. It seems to work for Acrobat Reader but not for Bloomberg
Terminal. When I do it by hand, it is fine. When I run the macro
below, I do get the last data I have stored to the clipboard before
running the macro i.e. the macro does not copy anything new. I tried
several time periods in Wait with no luck. Any idea?
Public Sub procGrabData()
Dim lngBlp As Long
lngBlp = DDEInitiate("winblp", "bbk")
Call DDEExecute(lngBlp, "<blp-1>")
Application.Wait (Now + TimeValue("0:00:05"))
SendKeys "^a", True
Application.Wait (Now + TimeValue("0:00:05"))
SendKeys "^c", True
Application.Wait (Now + TimeValue("0:00:05"))
AppActivate "Microsoft Excel"
ActiveSheet.PasteSpecial
Call DDETerminate(lngBlp)
End Sub
BTW, I have tried DataObject but the results are the same when I
change ActiveSheet.PasteSpecial with:
Dim objData As New DataObject
objData.GetFromClipboard
ActiveCell = objData.GetText
Thank you for your help,
Xavier