0

I am looking to select some data from an excel file which has a welcoming box. I am trying to get the data using a excel macro. I am struggling to figure out how to click on the pop-up box so that i can proceed with copying the data. The sendkeys function does not seem to be working.

Sub BAI()
Dim objEx As Object
Dim objExFile As Object

Set objEx = CreateObject("Excel.Application")
objEx.Visible = True

Set objExFile = objEx.Workbooks.Open("FileName")
Application.SendKeys ("ESC")
objExFile.Sheets("12Week").Select

Application.EnableEvents = False

objExFile.Save

Set objExFile = Nothing
Set objEx = Nothing
End Sub
braX
  • 11,506
  • 5
  • 20
  • 33
  • Does this answer your question? [Auto clicking on a message box using VBA](https://stackoverflow.com/questions/35549410/auto-clicking-on-a-message-box-using-vba) – braX Jun 01 '20 at 22:09
  • Unfortunately not, the file that I am looking to copy the data from is an external file which I download. It has the macro already in it showing the welcoming message. – Neeraj Agarwal Jun 01 '20 at 22:17
  • hold shift while you open it and none of the macros will run – braX Jun 01 '20 at 22:49
  • 1
    Have you tried disabling events before you open the workbook? Or see https://stackoverflow.com/questions/45283608/vba-that-doesnt-allow-auto-open-to-run/45284237#45284237 – Tim Williams Jun 01 '20 at 23:31
  • @TimWilliams Thanks. "Application.EnableEvents = False" worked. – Neeraj Agarwal Jun 02 '20 at 01:30

0 Answers0