I am trying to attach a file to an email body (Well at least bring up the prompt, because i've read it's extremely difficult to interact with the pop up box, unless someone has a way to do that.) and I need to click the "attach" button, and then click the "Browse this computer" button. My code is being slowed down because it has to iterate through the 500+ "Buttons" on the sheet, and then there is 2 "attach" buttons. Neither of them have an ID associated with them that I can use. Can someone help me figure out how to make this code more efficient and to end the For Each loop as soon as it finds the FIRST "Attach" button?
Set attach = ie.Document.GetElementsByTagName("button")
For Each Button In attach
If Button.Name = "Attach" Then
Button.Click
End If
Next
Set attach = ie.Document.GetElementsByTagName("button")
For Each Button In attach
If Button.Name = "Browse this computer" Then
Button.Click
End If
Next