Notices
Computer & Technology Related Post here for help and discussion of computing and related technology. Internet, TVs, phones, consoles, computers, tablets and any other gadgets.

Excel Linked Spreadsheets finding and changing..

Thread Tools
 
Search this Thread
 
Old 21 March 2002, 01:33 PM
  #1  
David_Wallis
Scooby Regular
Thread Starter
 
David_Wallis's Avatar
 
Join Date: Nov 2001
Location: Leeds - It was 562.4bhp@28psi on Optimax, How much closer to 600 with race fuel and a bigger turbo?
Posts: 15,239
Likes: 0
Received 1 Like on 1 Post
Post

Anybody got any apps / utils that can find linked excel spreadsheets and change them automatically??

Or any ideas on how this could be done?

David
Old 25 March 2002, 01:24 PM
  #2  
David_Wallis
Scooby Regular
Thread Starter
 
David_Wallis's Avatar
 
Join Date: Nov 2001
Location: Leeds - It was 562.4bhp@28psi on Optimax, How much closer to 600 with race fuel and a bigger turbo?
Posts: 15,239
Likes: 0
Received 1 Like on 1 Post
Post

Any Ideas?

David
Old 27 March 2002, 09:56 AM
  #3  
David_Wallis
Scooby Regular
Thread Starter
 
David_Wallis's Avatar
 
Join Date: Nov 2001
Location: Leeds - It was 562.4bhp@28psi on Optimax, How much closer to 600 with race fuel and a bigger turbo?
Posts: 15,239
Likes: 0
Received 1 Like on 1 Post
Post

think I maybe getting somewhere, this is what I have so far....

Sub Macro1()
alinks = ActiveWorkbook.LinkSources(xlOLELinks)
If Not IsEmpty(alinks) Then
For i = 1 To UBound(alinks)

iStartPos = (InStr(1, alinks(i), "|"))
iLength = ((Len(alinks(i)) - iStartPos) - 2)
strfileName = Mid$(alinks(i), iStartPos + 1, iLength)

MsgBox "Link " & i & " location is:" & Chr(13) & strfileName
strNewLocation = InputBox("Enter New Location", "Change")

ActiveWorkbook.ChangeLink alinks(i), strNewLocation, xlLinkTypeOLELinks
Next
End If
End Sub

but it doesnt seem to actually change / refresh the link...

David
Old 27 March 2002, 10:25 AM
  #4  
Crispin
Scooby Regular
 
Crispin's Avatar
 
Join Date: Jan 2001
Posts: 534
Likes: 0
Received 0 Likes on 0 Posts
Post

Heres what I did, I created one sheet, and then linked a value to another dell in another sheet and added 3 to it for a simple formula......


Then I saved both sheets and moved the linked sheet to my D drive root.....


Then I implemented your code in a command button on the linker sheet, and stepped through it, I changed a couple of bits and it worked fine for me, changed the link(s) and saved em, then refreshed the sheet.....heres your code Version 2....
(What type of links are you changing exactly though - OLE or Excel - though you could loop the code for both of these types if you wanted)


Public Sub ChangeLinks()
alinks = ActiveWorkbook.LinkSources(xlExcelLinks)
If Not IsEmpty(alinks) Then
For i = 1 To UBound(alinks)

'not sure why you are using the following three lines, they seem to chop off the filename for me........
iStartPos = (InStr(1, alinks(i), "|"))
iLength = ((Len(alinks(i)) - iStartPos) - 2)
strfileName = Mid$(alinks(i), iStartPos + 1, iLength)

MsgBox "Link " & i & " location is:" & Chr(13) & strfileName
strNewLocation = InputBox("Enter New Location", "Change")

ActiveWorkbook.ChangeLink alinks(i), strNewLocation, xlLinkTypeExcelLinks
ActiveWorkbook.Save
ActiveWorkbook.RefreshAll
Next
End If
End Sub
Old 27 March 2002, 01:14 PM
  #5  
David_Wallis
Scooby Regular
Thread Starter
 
David_Wallis's Avatar
 
Join Date: Nov 2001
Location: Leeds - It was 562.4bhp@28psi on Optimax, How much closer to 600 with race fuel and a bigger turbo?
Posts: 15,239
Likes: 0
Received 1 Like on 1 Post
Post

I was using that to find the | as the result i get if I do

Debug.print alinks(i) is the following

Excel.Sheet.8|\\cplntmbpcs03\dwallis$\My Documents\Notes Migration - Upto 4.6.3a Machines.xls!'

So I work out where the | is + 1 for the start of the file name then subtract that from the length and remove 2 off that to get the filename...

I was using ole as we were checking for linked sheets not linked cells...

David

Old 27 March 2002, 01:19 PM
  #6  
David_Wallis
Scooby Regular
Thread Starter
 
David_Wallis's Avatar
 
Join Date: Nov 2001
Location: Leeds - It was 562.4bhp@28psi on Optimax, How much closer to 600 with race fuel and a bigger turbo?
Posts: 15,239
Likes: 0
Received 1 Like on 1 Post
Post

also if I change it by entering the new value as

Excel.Sheet.8|\\cplntmbpcs03\dwallis$\My Documents\Notes.xls!'

it sort of works... but it doesnt open the new file... it just sort of finds the old link even though I have deleted the other file..

if I dont put the cr@p in then I get a dde error...

When you highlight the link it shows the new path and location but doesnt actually use the new data... it somehow just keeps the other??

Does this make sense??

David

[Edited by David_Wallis - 3/27/2002 1:20:23 PM]
Old 27 March 2002, 02:06 PM
  #7  
Crispin
Scooby Regular
 
Crispin's Avatar
 
Join Date: Jan 2001
Posts: 534
Likes: 0
Received 0 Likes on 0 Posts
Post

Are you doing the save and RefreshAll?
Old 27 March 2002, 03:28 PM
  #8  
David_Wallis
Scooby Regular
Thread Starter
 
David_Wallis's Avatar
 
Join Date: Nov 2001
Location: Leeds - It was 562.4bhp@28psi on Optimax, How much closer to 600 with race fuel and a bigger turbo?
Posts: 15,239
Likes: 0
Received 1 Like on 1 Post
Post

I am, but it doesnt make any difference..

???

David
Related Topics
Thread
Thread Starter
Forum
Replies
Last Post
Mattybr5@MB Developments
Full Cars Breaking For Spares
28
28 December 2015 11:07 PM
Mattybr5@MB Developments
Full Cars Breaking For Spares
12
18 November 2015 07:03 AM
leg200
Subaru Parts
5
07 October 2015 07:31 AM
has-scooby
Subaru Parts
4
06 October 2015 03:47 PM
bluebullet29
General Technical
9
05 October 2015 02:17 PM



Quick Reply: Excel Linked Spreadsheets finding and changing..



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