该代码将一个服务器名称替换为Excel连接中的另一个服务器名称。

vbscript
阅读 27 收藏 0 点赞 0 评论 0

v1_UpdateCONNECTIONS.vbs
Sub UpdateCONNECTIONS()
Dim CON As Variant, NewSERVER As String, OldSERVER As String, SvrConAVAL As Integer

If MsgBox("The action will requir you to have both, New & Old Server Name!", vbYesNo, "Server Name Confirm?") = vbNo Then Exit Sub
    OldSERVER = InputBox("Please enter the new server name:", "New Server", "nbmsaadev01.mgmt.lab.eng.btc.netapp.in")
    NewSERVER = InputBox("Please enter the new server name:", "New Server", "amsmsaapp02-prd.hq.netapp.com")

    For Each CON In ActiveWorkbook.Connections
        CON.OLEDBConnection.Connection = Replace(CON.OLEDBConnection.Connection, OldSERVER, NewSERVER)
    Next CON
End Sub
UpdateCONNECTIONS.vbs
Sub UpdateCONNECTIONS()
Dim CON As Variant, NewSERVER As String, OldSERVER As String

NewSERVER = "amsmsaapp02-prd.hq.netapp.com"
OldSERVER = "nbmsaadev01.mgmt.lab.eng.btc.netapp.in"

  For Each CON In ActiveWorkbook.Connections
      CON.OLEDBConnection.Connection = Replace(CON.OLEDBConnection.Connection, OldSERVER, NewSERVER)
  Next CON

End Sub
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号