title: How to get approximate x,y coordinates of an object on a webpage?
body: <p>I'm new to this website as well as vba and html (started learning/using both a month ish ago) so please be forgiving with my quality of question. The code I've put below is what I've written to upload values from an excel file onto a website. The part I'm struggling with is the line <strong><em>SetCursorPos x, y</em></strong>. So to explain why I have that there in the first place: I needed to click a button "Add" at the bottom of a user form that was initially summoned by clicking another button "Add Client". For some reason, <strong>.Click</strong> wasn't working here. So to solve this problem, I found code online for simulating a mouse click. That worked but I needed to place the cursor on the "Add" button myself. I did find that I could use a SetCursorPos function to place the cursor where I needed but I'm not sure how to get the x,y coordinates of the button in the first place. I've tried parsing through the source code but I can't find all the location information I need for the button object. If I click "layout" when I've selected the html code that corresponds to the Add button, I see the information I'm looking for, but I don't know how to extract this either. I'm not getting anywhere from my online searches. Any suggestions or ideas??</p>
  
  <p>Thank you in advance.</p>
  
  <pre><code>Sub JoistUpload()
  
  Dim TextFile As Integer
  Dim FilePath As String
  Dim FileContent As String
  
  Dim NumberOfModulesToRun As Integer
  NumberOfModulesToRun = ThisWorkbook.Sheets("Overall").Range("B12").Value
  
  Dim ModulesToRun()     'Dynamic Array
  ReDim ModulesToRun(NumberOfModulesToRun - 1)
  j = 0
  For i = 2 To 10
  If ThisWorkbook.Sheets("Overall").Cells(i, 2).Value = 1 Then
      ModulesToRun(j) = ThisWorkbook.Sheets("Overall").Cells(i, 1).Value
      j = j + 1
  End If
  Next i
  
  
  Set objIE = CreateObject("InternetExplorer.Application")
  
  With objIE
      .Visible = True
      .Navigate "https://my.joistapp.com/dashboard/estimate/new"
      Do While .Busy Or .readyState &lt;&gt; 4
          DoEvents
      Loop
  
      Application.Wait (Now + TimeValue("0:00:10"))
  
      .Document.GetElementsByClassName("ember-view document-header-client waves-effect waves-green btn-flat")(0).Click
  
  
      .Document.getElementbyID("name").Value = ThisWorkbook.Sheets("Overall").Range("O2").Text
      .Document.getElementbyID("email").Select
      Application.SendKeys ThisWorkbook.Sheets("Overall").Range("O3").Text, True
      Application.Wait (Now + TimeValue("0:00:2"))
      .Document.getElementbyID("phoneMobile").Select
      Application.SendKeys ThisWorkbook.Sheets("Overall").Range("O4").Text, True
      Application.Wait (Now + TimeValue("0:00:2"))
      .Document.getElementbyID("phoneOther").Select
      Application.SendKeys ThisWorkbook.Sheets("Overall").Range("O5").Text, True
      Application.Wait (Now + TimeValue("0:00:2"))
      .Document.getElementbyID("address1").Select
      Application.SendKeys ThisWorkbook.Sheets("Overall").Range("O7").Text, True
      Application.Wait (Now + TimeValue("0:00:2"))
      .Document.getElementbyID("address2").Select
      Application.SendKeys ThisWorkbook.Sheets("Overall").Range("O8").Text, True
      Application.Wait (Now + TimeValue("0:00:2"))
      .Document.getElementbyID("city").Select
      Application.SendKeys ThisWorkbook.Sheets("Overall").Range("O9").Text, True
      Application.Wait (Now + TimeValue("0:00:2"))
      .Document.getElementbyID("state").Select
      Application.SendKeys ThisWorkbook.Sheets("Overall").Range("O10").Text, True
      Application.Wait (Now + TimeValue("0:00:2"))
      .Document.getElementbyID("zip").Select
      Application.SendKeys ThisWorkbook.Sheets("Overall").Range("O11").Text, True
      Application.Wait (Now + TimeValue("0:00:2"))
      .Document.getElementbyID("ember1872").Select
      Application.SendKeys ThisWorkbook.Sheets("Overall").Range("O12").Text, True
  
  
      Application.Wait (Now + TimeValue("0:00:02"))
      'SetCursorPos x, y
      mouse_event MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0
      mouse_event MOUSEEVENTF_LEFTUP, 0, 0, 0, 0
  
      For i = 0 To NumberOfModulesToRun - 1
  
          FilePath = "C:\Users\Bloom\Documents\Renovation Express\Quote Code\" &amp; ModulesToRun(i) &amp; "Module.txt"
          TextFile = FreeFile
          Open FilePath For Input As TextFile
          FileContent = Input(LOF(TextFile), TextFile)
          .Document.GetElementsByClassName("ember-view waves-effect waves-green new-document-item btn-green btn-flat waves-effect waves-light button-with-image")(0).Click
          .Document.GetElementsByClassName("ember-view btn-green btn waves-effect waves-light")(2).Click
          .Document.GetElementsByClassName("unstyled materialize-textarea ember-view ember-text-area")(i).Value = FileContent
          .Document.GetElementsByClassName("no-padding unstyled is-valid ember-view ember-text-field")(i).Value = ModulesToRun(i)
          .Document.GetElementsByClassName("no-padding unstyled ember-view ember-text-field")(3 * (i) + 1).Value = ThisWorkbook.Sheets("Overall").Range("A:A").Find(What:=ModulesToRun(i)).Offset(0, 3).Value
          .Document.GetElementsByClassName("document-tax-col placeholder")(0).Click
          .Document.GetElementsByClassName("toggle-bar")(3).Click
          .Document.GetElementsByClassName("ember-view btn-green btn waves-effect waves-light")(3).Click
          Close TextFile
  
          Next i
  
      FilePath = "C:\Users\Bloom\Documents\Renovation Express\Quote Code\NoteForClient.txt"
      TextFile = FreeFile
      Open FilePath For Input As TextFile
      FileContent = Input(LOF(TextFile), TextFile)
      .Document.GetElementsByClassName("materialize-textarea ember-view ember-text-area")(NumberOfModulesToRun).Value = FileContent
      Close TextFile
  
      .Document.getElementbyID("issued-date").Click
      .Document.GetElementsByClassName("btn-flat picker__today")(0).Click
  
  
  End With
  
  End Sub
  </code></pre>
  
  <p>Some of the source code related to the form where the Add button is:</p>
  
  <pre><code>&lt;/p&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/section&gt;&lt;div 
  class="modaler"&gt;&lt;div class="modal modal-view" style="top: 70.3px; width: 
  700px; height: 562.4px; display: block; min-height: 0px; max-width: 700px;" 
  data-is-push="false"&gt;&lt;div class="ember-view modal-wrapper" id="ember1841"&gt;
  &lt;div class="modal-header"&gt;&lt;div class="title"&gt;&lt;!----&gt;&lt;span&gt;New Client&lt;/span&gt;
  &lt;/div&gt;&lt;div class="actions"&gt;&lt;a class="ember-view btn-green btn waves-effect 
  waves-light" id="ember1842"&gt;&lt;!----&gt;&lt;span&gt;My Clients&lt;/span&gt;&lt;!----&gt;&lt;/a&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class="modal-content"&gt;&lt;p&gt;&lt;div class="ember-view" id="ember1851"&gt;
  &lt;div class="ember-view col-header form-header" id="ember1860"&gt;&lt;h3 
  class="col-header-title"&gt;Basic Information&lt;/h3&gt;&lt;/div&gt;&lt;div class="ember-view 
  fixed-label input-field is-valid" id="ember1861"&gt;&lt;div class="joist-input-
  container-wrapper"&gt;&lt;input class="  is-valid   ember-view ember-text-field" 
  id="name" type="text"&gt;&lt;label class="false active" for="name"&gt;Name&lt;/label&gt;&lt;!-
  ---&gt;&lt;/div&gt;&lt;!----&gt;&lt;/div&gt;&lt;div class="ember-view fixed-label input-field is-
  valid" id="ember1862"&gt;&lt;div class="joist-input-container-wrapper"&gt;&lt;input 
  class="  is-valid   ember-view ember-text-field" id="email" type="text"&gt;
  &lt;label class="false" for="email"&gt;Email Address&lt;/label&gt;&lt;!----&gt;&lt;/div&gt;&lt;!----&gt;
  &lt;/div&gt;&lt;div class="ember-view fixed-label input-field is-valid" 
  id="ember1863"&gt;&lt;div class="joist-input-container-wrapper"&gt;&lt;input class="  
  is-valid   ember-view ember-text-field" id="phoneMobile" type="text"&gt;&lt;label 
  class="false" for="phoneMobile"&gt;Phone (mobile)&lt;/label&gt;&lt;!----&gt;&lt;/div&gt;&lt;!----&gt;
  &lt;/div&gt;&lt;div class="ember-view fixed-label input-field is-valid" 
  id="ember1864"&gt;&lt;div class="joist-input-container-wrapper"&gt;&lt;input class="  
  is-valid   ember-view ember-text-field" id="phoneOther" type="text"&gt;&lt;label 
  class="false" for="phoneOther"&gt;Phone (other)&lt;/label&gt;&lt;!----&gt;&lt;/div&gt;&lt;!----&gt;
  &lt;/div&gt;&lt;div class="ember-view col-header form-header" id="ember1865"&gt;&lt;h3 
  class="col-header-title"&gt;Additional Information&lt;/h3&gt;&lt;/div&gt;&lt;div class="ember-
  view fixed-label input-field is-valid" id="ember1866"&gt;&lt;div class="joist-
  input-container-wrapper"&gt;&lt;input class="  is-valid   ember-view ember-text-
  field" id="address1" type="text"&gt;&lt;label class="false" 
  for="address1"&gt;Address&lt;/label&gt;&lt;!----&gt;&lt;/div&gt;&lt;!----&gt;&lt;/div&gt;&lt;div class="ember-
  view fixed-label input-field is-valid" id="ember1867"&gt;&lt;div class="joist-
  input-container-wrapper"&gt;&lt;input class="  is-valid   ember-view ember-text-
  field" id="address2" type="text"&gt;&lt;label class="false" for="address2"&gt;Address 
  2&lt;/label&gt;&lt;!----&gt;&lt;/div&gt;&lt;!----&gt;&lt;/div&gt;&lt;div class="ember-view fixed-label input-
  field is-valid" id="ember1868"&gt;&lt;div class="joist-input-container-wrapper"&gt;
  &lt;input class="  is-valid   ember-view ember-text-field" id="city" 
  type="text"&gt;&lt;label class="false" for="city"&gt;City&lt;/label&gt;&lt;!----&gt;&lt;/div&gt;&lt;!----&gt;
  &lt;/div&gt;&lt;div class="ember-view fixed-label input-field is-valid" 
  id="ember1869"&gt;&lt;div class="joist-input-container-wrapper"&gt;&lt;input class="  
  is-valid   ember-view ember-text-field" id="state" type="text"&gt;&lt;label 
  class="false" for="state"&gt;State&lt;/label&gt;&lt;!----&gt;&lt;/div&gt;&lt;!----&gt;&lt;/div&gt;&lt;div 
  class="ember-view fixed-label input-field is-valid" id="ember1870"&gt;&lt;div 
  class="joist-input-container-wrapper"&gt;&lt;input class="  is-valid   ember-view 
  ember-text-field" id="zip" type="text"&gt;&lt;label class="false" for="zip"&gt;Zip / 
  Postal Code&lt;/label&gt;&lt;!----&gt;&lt;/div&gt;&lt;!----&gt;&lt;/div&gt;&lt;div class="ember-view input-    
  field input-field-textarea fixed-label input-field is-valid" id="ember1871"&gt;
  &lt;div class="joist-input-container-wrapper"&gt;&lt;textarea class="materialize-    
  textarea  ember-view ember-text-area" id="ember1872" style="height: 23px;"&gt;
  &lt;!----&gt;&lt;br&gt;&lt;/textarea&gt;&lt;label class="false"&gt;Private Notes&lt;/label&gt;&lt;/div&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;/p&gt;&lt;/div&gt;&lt;div class="modal-action"&gt;&lt;!----&gt;&lt;a class="ember-view btn-
  grey btn waves-effect waves-light" id="ember1873"&gt;&lt;!----&gt;&lt;span&gt;Cancel&lt;/span&gt;
  &lt;!----&gt;&lt;/a&gt;&lt;a class="ember-view btn-green btn waves-effect waves-light" 
  id="ember1874"&gt;&lt;!----&gt;&lt;span&gt;Add&lt;/span&gt;&lt;!----&gt;&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;
  &lt;div class="modal fade alert-view"&gt;&lt;!----&gt;&lt;/div&gt;&lt;div class="ember-view 
  select-view" id="ember679"&gt;&lt;!----&gt;&lt;/div&gt;&lt;div class="loading-overlay" 
  style="display: none;" data-ember-action="680"&gt;&lt;/div&gt;&lt;/div&gt;&lt;div 
  class="material-tooltip"&gt;&lt;span&gt;Estimates&lt;/span&gt;&lt;div class="backdrop" 
  style="left: 0px; top: 0px;"&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="material-tooltip"&gt;
  &lt;span&gt;Invoices&lt;/span&gt;&lt;div class="backdrop" style="left: 0px; top: 0px;"&gt;
  &lt;/div&gt;&lt;/div&gt;&lt;div class="material-tooltip"&gt;&lt;span&gt;Clients&lt;/span&gt;&lt;div 
  class="backdrop" style="left: 0px; top: 0px;"&gt;&lt;/div&gt;&lt;/div&gt;&lt;div 
  class="material-tooltip"&gt;&lt;span&gt;Items&lt;/span&gt;&lt;div class="backdrop" 
  style="left: 0px; top: 0px;"&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="material-tooltip"&gt;
  &lt;span&gt;Settings&lt;/span&gt;&lt;div class="backdrop" style="left: 0px; top: 0px;"&gt;
  </code></pre>