title: Replace file path in VBA with user name
body: <p>I have an Excel file with VBA written on it that draws information from a file on my computer. The Excel file is on a network folder and I would like for other users on the network to use it as well. However, I have hardcoded the file path on the VBA and, as such, whenever another user opens it, it looks for a file that is not available.</p>
  
  <p>This is the path I would like to change:</p>
  
  <pre><code>C:\Users\User1\Documents\The Market in\DATA FOR REPORTS.xlsx
  </code></pre>
  
  <p>The only difference on the paths would be the user's name: User1, user2, etc.</p>
  
  <p>How can I write the VBA code in order for it to replace the username in the file path with the Windows user name opening it?</p>
  
  <p>I have tried to use wild card and also tried to use ENVIRON("username") but have not been successful.</p>
  
  <p>The code I want to replace is what's below:</p>
  
  <pre><code>Private Sub Workbook_Open()
  
  Application.Visible = False
  WelcomeForm.Show
  Workbooks.Open ("C:\Users\User1\Documents\The Market in\DATA FOR REPORTS.xlsx")
  
  End Sub
  </code></pre>
  
  <p>This is what I did using ENVIRON:</p>
  
  <pre><code>Private Sub Workbook_Open()
  
  Dim username As String
  
  username = Environ("username")
  
  Application.Visible = False
  WelcomeForm.Show
  Workbooks.Open ("C:\Users\&amp;username&amp;\Documents\The Market in\DATA FOR REPORTS.xlsx")
  
  End Sub
  </code></pre>
  
  <p>Thank you very much</p>