title: How to open excel workbook which needs login in vb?
body: <p>I created an excel1 which has a login function (I've the username and password):</p>
  
  <p>Pic: showing login window. (but I can't post the pic here because I don't have 10 reputation...)</p>
  
  <p>Now I have another excel2 which need to read some information from excel1, and I want this can be done by just click a button, so I use vb.</p>
  
  <p>But how to sent username&amp;password to excel1 and open excel1 in background(I don't want the open process showing on screen).</p>
  
  <p>Thanks</p>
  
  <p>Add more description of my "login" window:</p>
  
  <p>I insert an VBA Userform as the login window, it includes:</p>
  
  <pre><code>1, username_box: user can input login name here
  
  2, pw_box: user can input password here
  
  3, login_button: if click this button, sub login_button_Click() will be triggered
  
  4, quit_button: if click this button, login will be cancelled
  </code></pre>
  
  <p>Private Sub login_button_Click()</p>
  
  <pre><code>Dim login_flag As Boolean
  login_flag = False
  'there is a sheet "users" which recorded the username and its password
  For r = 2 To 100 Step 1
      If username_box.Text = Sheets("users").Cells(r, 1).Value And pw_box.Text = Sheets("users").Cells(r, 2).Value Then
          login_flag = True
          Application.Visible = True
          login_window.Hide
          pw_box = ""
      End If
  Next r
  
  If login_flag = False Then
      MsgBox "Input wrong"
      pw_box = ""
  End If
  </code></pre>
  
  <p>End Sub</p>