Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Using Macro to update Links

I would like change links using excel based on a value I put in a cell in a
master workbook.

I am having difficulty getting it to work, I am not a program writer, but a
recorder and then make modifications.

Dim ITOPacingOld
Set ITOPacingOld = Worksheets("Master").Range("E15")
Dim SelectITOPacingNew
Set SelectPartsPacingNew =
Worksheets("Master").Range("F14")ActiveWorkbook.Ch angeLink
Name:=(ITOPacingOld), NewName:=(SelectITOPacingNew), Type:=xlExcelLinks

Where "ITOPacingOld" is the old link and "ITOPacingNew" is the new link.

Thanks.


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 132
Default Using Macro to update Links

Thom, is the ActiveWorkbook the file that currently contains the links?

Here is the code that I use for changing links, slightly modified for your
situation.



Sub Fill()
Dim ITOPacingOld
Dim SelectITOPacingNew

Set ITOPacingOld = Worksheets("Master").Range("E15")
Set SelectPartsPacingNew = Worksheets("Master").Range("F14")

Call ChangeLinks(SelectPartsPacingNew.Value, ITOPacingOld.Value)

End Sub



' Change links from strWorkbookOld to strWorkbookNew workbook
Public Sub ChangeLinks(strWorkbookNew As String, strWorkbookOld As String)
Dim wbk As Object

On Error GoTo ErrorHandler

' Assumes that new workbook is open
Set wbk = Application.Workbooks(strWorkbookNew)

If (Not (IsEmpty(wbk.LinkSources(xlExcelLinks)))) Then
wbk.ChangeLink Name:=strWorkbookOld, NewName:=strWorkbookNew,
Type:=xlExcelLinks
End If

Exit Sub

ErrorHandler:
MsgBox Err.Number, Err.Description, "ChangeLinks"
Exit Sub
Resume
End Sub


Let me know if this works for you.

Regards,
Bill



"Thom Ernest" wrote:

I would like change links using excel based on a value I put in a cell in a
master workbook.

I am having difficulty getting it to work, I am not a program writer, but a
recorder and then make modifications.

Dim ITOPacingOld
Set ITOPacingOld = Worksheets("Master").Range("E15")
Dim SelectITOPacingNew
Set SelectPartsPacingNew =
Worksheets("Master").Range("F14")ActiveWorkbook.Ch angeLink
Name:=(ITOPacingOld), NewName:=(SelectITOPacingNew), Type:=xlExcelLinks

Where "ITOPacingOld" is the old link and "ITOPacingNew" is the new link.

Thanks.


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
macro for update links damiand_1982[_5_] Excel Programming 1 August 15th 06 01:49 PM
A macro to update links [email protected] Excel Programming 3 August 8th 06 05:02 PM
Update links macro Spike Excel Programming 5 April 21st 06 08:58 PM
update links when Macro ends Gato Excel Programming 0 February 21st 06 07:09 PM
Macro after Update of Links Mr.T[_2_] Excel Programming 0 November 22nd 05 10:16 AM


All times are GMT +1. The time now is 04:31 PM.

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

About Us

"It's about Microsoft Excel"