×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Rename Connection Name (Data Connection)
2

Rename Connection Name (Data Connection)

Rename Connection Name (Data Connection)

(OP)
Hi
I have a workbook with 10+ connections.
Some connections are not being used.
These connections are used to produced an OLAP-type PVT.

Each connection having their own connection name.
Naming convention can be random.

I'm looking for a vba code to loop through all connections in the workbook
and
rename them to Connection 1, Connection 2, Connection 3, etc...

Many Thanks in advance for your assistance.

Regards,
arv

RE: Rename Connection Name (Data Connection)

For instance:
Sub RenameConnections()
Dim conn As WorkbookConnection
For Each conn In ThisWorkbook.Connections
    i = 1
    With conn
        .Description = "Old name: " & .Name
        .Name = "Connection " & i
        i = i + 1
    End With
Next
End Sub 

combo

RE: Rename Connection Name (Data Connection)

(OP)
Hi combo
Thanks for the code.

It changes one of the connection name then came up with an error.
Run time error 5. Invalid procedure call or argument.

It appears that it is trying to rename the same connection when it loops.
It does not seem to have a sequence from top to bottom or bottom to top.

Regards,
arv

RE: Rename Connection Name (Data Connection)

move

i=1

before the For Each line

RE: Rename Connection Name (Data Connection)

(OP)
Thanks strongm.
Issue resolved.

Many Thanks to both Combo and strongm!

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login


Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close