Select an option that is only possible by mouse click with vba

3

I'm trying to develop a script with vba, in excel , to facilitate a routine we have at work, which inserts about 9,000 data into the internal system. We are currently manually inserting this data. This data will never be the same since it is obtained after multiple document checks.

Because this system is a page, accessed by browser , I am using Application.SendKeys to be able to manipulate it. It has two logins . The first is quiet to do and after doing so, it shows us a selection of systems (as shown below)

Toaccessthesecondlogin,wehavetoselectthe"PERSONAL". But you can only select it using two mouse clicks. Press TAB and use the arrows until you reach the option that I need and then press ENTER does not resolve.

Would it be possible to do this with VBA? I have already seen that there is something like .click , but I have no idea how I would do it.

The code to generate the image frame is below:

<!-- QUADRO DE SELECIONAR O SISTEMA-->
<span id="pnlUsuarioSistema_span" style = "position:absolute;top:210px;left:258px;height:197px;width:321px;background-color:F2F4F2;border-color:004080;border-style:Solid;border-width:1px;font-family:Verdana;font-size:11;font-style:normal;font-weight:normal;-moz-box-sizing:border-box;">
<label name="lblTexto" id="lblTexto" style = "background-color:F2F4F2;color:004080;font-family:Verdana;font-size:12;font-style:normal;font-weight:bold;height:21px;left:15px;position:absolute;top:15px;width:303px;">Selecione o sistema que deseja ingressar:</label>
<select  name="usrSysList" id="usrSysList" size="2" originalClass="DBList" style = "font-family:Verdana;font-size:12;font-style:normal;font-weight:normal;height:141px;left:17px;position:absolute;top:36px;width:285px;" ondblclick="openNewSession()">
<option value="http://(...)MAV">MAV</option>
<option value="http://(...)ORCOM">ORCOM</option>
<option value="http://(...)PESSOAL">PESSOAL</option>
</select>
</span>
<!-- FIM QUADRO -->
    
asked by anonymous 13.06.2016 / 04:20

1 answer

2

I've been reading the links, which @LuizVieira made available and helped a lot in understanding what I needed. But it was not possible to do exactly what I was looking for, because of my lack of knowledge.

That's when I got to this link . , which has the code below and it, in a different way, did what I needed, but not how I would like it. But the problem has been solved.

Public Declare Function SetCursorPos Lib "user32" (ByVal x As Long, ByVal y As Long) As Long
Public Declare Sub mouse_event Lib "user32" (ByVal dwFlags As Long, ByVal dx As Long, ByVal dy As Long, ByVal cButtons As Long, ByVal dwExtraInfo As Long)
Public Const MOUSEEVENTF_LEFTDOWN = &H2
Public Const MOUSEEVENTF_LEFTUP = &H4
Public Const MOUSEEVENTF_RIGHTDOWN As Long = &H8
Public Const MOUSEEVENTF_RIGHTUP As Long = &H10

Private Sub SingleClick()
  SetCursorPos 100, 100 'x and y position
  mouse_event MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0
  mouse_event MOUSEEVENTF_LEFTUP, 0, 0, 0, 0
End Sub

Private Sub DoubleClick()
  'Double click as a quick series of two clicks
  SetCursorPos 100, 100 'x and y position
  mouse_event MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0
  mouse_event MOUSEEVENTF_LEFTUP, 0, 0, 0, 0
  mouse_event MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0
  mouse_event MOUSEEVENTF_LEFTUP, 0, 0, 0, 0
End Sub

Private Sub RightClick()
  'Right Click
  SetCursorPos 200, 200 'x and y position
  mouse_event MOUSEEVENTF_RIGHTDOWN, 0, 0, 0, 0
  mouse_event MOUSEEVENTF_RIGHTUP, 0, 0, 0, 0
End Sub
    
14.06.2016 / 21:49