title: VBA - Compile error: Expected: If or Select or Sub or Function or Property or Type or With or Enum or end of statement
body: <p>Forgive me for the noob question. Working in VBA is not my normal job. </p>
  
  <p>I get the error listed in the title. The offending code is this:</p>
  
  <pre><code>While index &lt;= 10
      index = index + 1
  End While
  </code></pre>
  
  <p>I can't imagine what could be wrong with that, seeing that it is copied directly from the documentation: <a href="https://docs.microsoft.com/en-us/dotnet/visual-basic/language-reference/statements/while-end-while-statement" rel="nofollow noreferrer">https://docs.microsoft.com/en-us/dotnet/visual-basic/language-reference/statements/while-end-while-statement</a></p>
  
  <p>Seeing that the code can't be the problem, I'm supposing the problem must be something in the context, but before I put this block in, it was working fine.</p>
  
  <p>This block of code is part of a simple, private subroutine which declares a variable, assign a value to it, and then writes it into a file, like so:</p>
  
  <pre><code>Private Sub btnExpAll_Click()
  Dim sFldr As String
  sFldr = BrowseFolder("Where do you want to export the files?") 
  If sFldr = "" Then Exit Sub                                    
  DoCmd.Hourglass True
  
  Dim sListLocal As String
  Dim index As Integer
  
  Dim strInputFileNameLocal As String
  
  sListLocal = ""
  
  index = 0
  
  While index &lt;= 10
      index = index + 1
  End While
  
  strInputFileNameLocal = sFldr &amp; "\list-local.html"
  
  Open strInputFileNameLocal For Output As #1
  Print #1, sListLocal
  Close #1
  
  DoCmd.Hourglass False
  
  End Sub
  </code></pre>
  
  <p>The idea is to add more text to the file as we go through the while loop based on certain conditions - but since I can't even get the while loop to compile...</p>