title: Excel VBA - save current web address to use in another sub routine
body: <p>Quick question I hope there is an easy answer.
  I have a sub routine that navigates through a webpage. "Sub Navigate()"</p>
  
  <pre><code>Dim ie As Object
  Set ie = CreateObject("internetexplorer.application")
  ie.Visible = True
  </code></pre>
  
  <p>and so on.....</p>
  
  <p>This part works fine and I successfully navigate through IE as needed. My next step comes from a separate sub routine "Sub copyimage()" I have designed where I pull images off the active page. However I cannot figure out how to use the open webpage for this.</p>
  
  <p>The "Sub Copyimage()" sub works if I navigate directly to the URL within this sub. But I want to be able to get there from the work of my "Sub Navigate()" code.</p>
  
  <p>I would like to be able to call the Copyimage() subroutine from the navigate() subroutine.</p>
  
  <p>Please help</p>
  
  <p>Here is full code from the first sub:</p>
  
  <pre><code>Sub FMSWebsite()
  Dim strURL
  Dim ie As Object
  Set ie = CreateObject("InternetExplorer.Application")
  strURL = "https://functionalmovement.com/login?return=%2F"
  ie.Navigate strURL
  ie.Visible = True
  Do While (ie.Busy Or ie.READYSTATE &lt;&gt; 4)
  DoEvents
  Loop
  ie.Document.forms(0).all("Username").Value = Worksheets("Cover").Range("E8")
  ie.Document.forms(0).all("Password").Value = Worksheets("Cover").Range("E10")
  Do While (ie.Busy Or ie.READYSTATE &lt;&gt; 4)
  DoEvents
  Loop
  
  ie.Document.forms(0).submit
  Do While (ie.Busy Or ie.READYSTATE &lt;&gt; 4)
  DoEvents
  Loop
  
  Application.Wait (now + TimeValue("0:00:01"))
  ie.Navigate ("http://functionalmovement.com/pro/clients")
  Do While (ie.Busy Or ie.READYSTATE &lt;&gt; 4)
  DoEvents
  Loop
  
  
  ie.Document.forms(1).all("gvClients$DXFREditorcol1").Value = Worksheets("Template").Range("X2")
  ie.Document.forms(1).all("gvClients$DXFREditorcol1").Select
  
  SendKeys String:="{enter}", Wait:=True
  
  Application.Wait (now + TimeValue("0:00:03"))
  Do While (ie.Busy Or ie.READYSTATE &lt;&gt; 4)
  DoEvents
  Loop
  
  Dim e
  For Each e In ie.Document.getElementsByTagName("strong")
  If e.innerText = "Client Workouts" Then
  e.ParentElement.Click
  Exit For
  End If
  Next
  
  Application.Wait (now + TimeValue("0:00:01"))
  Do While (ie.Busy Or ie.READYSTATE &lt;&gt; 4)
  DoEvents
  Loop
  
  For Each e In ie.Document.getElementsByTagName("span")
  If e.innerText = "Create a New Workout" Then
  e.ParentElement.Click
  Exit For
  End If
  Next
  Do While (ie.Busy Or ie.READYSTATE &lt;&gt; 4)
  DoEvents
  Loop
  
  Application.Wait (now + TimeValue("0:00:01"))
  
  For Each e In ie.Document.getElementsByTagName("span")
  If e.innerText = "NEXT" Then
  e.ParentElement.Click
  Exit For
  End If
  Next
  Do While (ie.Busy Or ie.READYSTATE &lt;&gt; 4)
  DoEvents
  Loop
  
  Application.Wait (now + TimeValue("0:00:01"))
  Set goBtn = ie.Document.getElementById("newscreen")
  goBtn.Click
  
  Application.Wait (now + TimeValue("0:00:01"))
  Do While (ie.Busy Or ie.READYSTATE &lt;&gt; 4)
  DoEvents
  Loop
  </code></pre>
  
  <p>Fast Forward some code it ends like so:</p>
  
  <pre><code>For Each e In ie.Document.getElementsByTagName("span")
  If e.innerText = "Complete" Then
  e.ParentElement.Click
  Exit For
  End If
  Next
  Do While (ie.Busy Or ie.READYSTATE &lt;&gt; 4)
  DoEvents
  Loop
  
  Application.Wait (now + TimeValue("0:00:03"))
  Do While (ie.Busy Or ie.READYSTATE &lt;&gt; 4)
  DoEvents
  Loop
  For Each e In ie.Document.getElementsByTagName("span")
  If e.innerText = "View Assigned Workout" Then
  e.ParentElement.Click
  Exit For
  End If
  Next
  End Sub
  </code></pre>
  
  <p>My next sub starts with</p>
  
  <pre><code>Sub findimageA ()
  For Each Elem In ie.Document.getElementsByTagName("img")
  If Elem.getAttribute("title") = "Step 1" Then
  </code></pre>
  
  <p>How do I reference the web address I ended with in the first sub?</p>