Pause Macro Until File is Downloaded and Opened

jziobro4

New Member
Joined
Aug 11, 2016
Messages
2
Hello:

I have the below macro which pulls in an excel file from the Bloomberg application. Microsoft excel does not stop processing the VBA. I need the macro to stop until the file named "grid*.xls" is opened, and then start again so I can copy and paste the data.

Please advise - been stuck on this for a while


Sub GetBBGFile()


AppActivate ("2-BLOOMBERG")




Application.SendKeys "CTS~", False
Application.Wait Now() + TimeValue("00:00:01")
Application.SendKeys "1~", False
Application.Wait Now() + TimeValue("00:00:01")
Application.SendKeys "TH10~", False
Application.Wait Now() + TimeValue("00:00:03")
Application.SendKeys "14~", False
Application.Wait Now() + TimeValue("00:00:01")
Application.SendKeys "2~", False




End Sub


Sub Copy()


Call GetBBGFile


Windows("London eSpeed 30019491 .xlsm").Activate


For Each w In Workbooks
If w.Name Like "*grid*" Then
Windows(w.Name).Activate
Exit For
End If
Next w


Range("A3").Select
Range(Selection, Selection.End(xlDown)).Select
Range(Selection, Selection.End(xlToRight)).Select
Selection.Copy
Windows("London eSpeed 30019491 .xlsm").Activate
Sheets("BBG").Select
Range("A2").Select
Range("A2").Select
ActiveSheet.Paste
Sheets("Summary").Select


End Sub
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
You said "until the file named "grid*.xls" is opened." Where is the code that opens the file? Anyway, try putting "DoEvents" after the open command. See if it works.
 
Upvote 0
This macro exports a excel file from Bloomberg:

Sub GetBBGFile()


AppActivate ("2-BLOOMBERG")




Application.SendKeys "CTS~", False
Application.Wait Now() + TimeValue("00:00:01")
Application.SendKeys "1~", False
Application.Wait Now() + TimeValue("00:00:01")
Application.SendKeys "TH10~", False
Application.Wait Now() + TimeValue("00:00:03")
Application.SendKeys "14~", False
Application.Wait Now() + TimeValue("00:00:01")
Application.SendKeys "2~", False




End Sub


 
Upvote 0

Forum statistics

Threads
1,214,924
Messages
6,122,294
Members
449,077
Latest member
Rkmenon

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top