title: Modify existing excel Connection Name in VBA
body: <p>I need to update the Connection Name of an excel workbook's sql connection.  This is my attempt.  I have been able to modify the Connection String and Command Text by doing a standard replace.</p>
  
  <pre><code>Sub ConnectionString_modify()
  
  Dim i As Long
  Dim cnt As Long
  Dim modtext As String
  Dim modrange As String
  
  'Grab nummber of workbook connections
  cnt = ActiveWorkbook.Connections.Count
  
  For i = 1 To cnt
  
      'Changes to Connection string --This works
      modtext = ActiveWorkbook.Connections.Item(i).OLEDBConnection.Connection
      modtext = VBA.Replace(modtext, "_FY2013", "_FY2014")
      ActiveWorkbook.Connections.Item(i).OLEDBConnection.Connection = modtext
  
      'Changes Connection Name
      modname = ActiveWorkbook.Connections.Item(i).Name
      modname = VBA.Replace(modname, "_FY2013", "_FY2014")
      ActiveWorkbook.Connections.Item(i).Name = modname 
   Next i
  
  End sub
  </code></pre>
  
  <p>Any help would be great.  Thanks.</p>