title: Clear all query credentials from ODBS connection when an Excel file launches
body: <p>I am trying to clear all query credentials from my ODBS connection when an Excel file launches.</p>
  
  <p>The manual way to do this is: DATA -> GET <code>DATA -&gt; DATA SOURCE SETTINGS -&gt; CLEAR ALL PERMISSIONS.</code> </p>
  
  <p><a href="https://i.stack.imgur.com/IsUgj.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/IsUgj.png" alt="enter image description here"></a></p>
  
  <p>I tried:</p>
  
  <pre><code>Private Sub workbook_open()
      Dim MyCon As WorkbookConnection
      Dim ODBCMyCon As ODBCConnection
  
      For Each MyCon In ThisWorkbook.Connections
          Set ODBCMyCon = MyCon.ODBCConnection
          ODBCMyCon.SavePassword = False
      Next
  
      For Each MyCon In ThisWorkbook.Connections
          ODBCMyCon.connection.Refresh
      Next
  
      MsgBox ("Connection credentials are cleared")
  End Sub
  </code></pre>
  
  <p>How can I automatically clear permissions?</p>