Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Links / March 2005

Tip: Looking for answers? Try searching our database.

editing links

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
J. Freed - 16 Mar 2005 17:33 GMT
Is there a way to programmatically access links and change them in VBA?
Specifically, we're doing a migration and want to be able to change names of
the links in a spreadsheet from .123 to .xls (converting the source files,
then go back to the destination file and change all the extensions).

TIA.
Bill Manville - 16 Mar 2005 18:43 GMT
> Is there a way to programmatically access links and change them in VBA?
> Specifically, we're doing a migration and want to be able to change names of
> the links in a spreadsheet from .123 to .xls (converting the source files,
> then go back to the destination file and change all the extensions).

A macro like this should do it:

Sub ChangeLinksFrom123ToXLS()
 Dim vLinks
 Dim iLink As Integer
 vLinks = ActiveWorkbook.LinkSources(xlExcelLinks)
 If IsEmpty(vLinks) Then Exit Sub
 For iLink = LBound(vLinks) To UBound(vLinks)
   If Right(vLinks(iLink), 3) = "123" Then
     ActiveWorkbook.ChangeLink vLinks(iLink), _
        Left(vLinks(iLink), Len(vLinks(iLink)) - 3) & "xls", _
        xlExcelLinks
   End If
 Next
End Sub

Bill Manville
MVP - Microsoft Excel, Oxford, England
No email replies please - respond to newsgroup
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.