Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Changing Links in Excel with VBA

Does anyone know how to change links in Excel with VBA and
using variable names ??

I have an application that moves from one server to
several others. I can create the path that is the current
link as

Current_link_name

I can also create the target link to change to as

New_link_name

My problem is in getting VBA to change the links with the
two variable names, without "hard-wiring" the names into
the command.

Any thoughts ?

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Changing Links in Excel with VBA

You could do something along the lines of this:

Sub Tester20()
Dim OldPath As String
Dim NewPath As String
Dim sStr As String, sStr1 As String
Dim i As Long
Dim Alinks as Variant
OldPath = "whatever"
NewPath = "whatever"
Alinks = ActiveWorkbook.LinkSources(xlExcelLinks)
If Not IsEmpty(Alinks) Then
For i = LBound(Alinks) To UBound(Alinks)
If InStr(1, Alinks(i), OldPath, vbTextCompare) Then
sStr = Alinks(i)
sStr1 = Application.Substitute(sStr, OldPath, NewPath)
ActiveWorkbook.ChangeLink sStr, sStr1, xlLinkTypeExcelLinks
End If
Next
End If
End Sub

--
Regards,
Tom Ogilvy


Tom Hickey wrote in message
...
Does anyone know how to change links in Excel with VBA and
using variable names ??

I have an application that moves from one server to
several others. I can create the path that is the current
link as

Current_link_name

I can also create the target link to change to as

New_link_name

My problem is in getting VBA to change the links with the
two variable names, without "hard-wiring" the names into
the command.

Any thoughts ?



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Changing Data Links Frank Excel Discussion (Misc queries) 3 December 15th 09 07:11 PM
Changing Database links? RozBentley Excel Discussion (Misc queries) 3 May 1st 09 05:26 PM
Changing Links in 2007 CPA Dan Links and Linking in Excel 3 August 27th 07 05:40 PM
Edit Links: Changing links on a protected worksheet Halibut68 Excel Discussion (Misc queries) 0 April 28th 06 11:03 AM
Changing Links Paul Excel Discussion (Misc queries) 0 March 30th 05 05:59 PM


All times are GMT +1. The time now is 06:43 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"