Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 88
Default Breaking excel links in code?

Anyone know how to break external links from one spreadsheet to
another in Excel. I have used the code
ChDir "C:\Documents and Settings\fdxuser\My Documents
\Flight Loads\"
ActiveWorkbook.BreakLink Name:=FileToOpen,
Type:=xlExcelLinks
But I get an error msg and it doesn't actually break the links...

Thanks,
chet

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 39
Default Breaking excel links in code?

A quick question, what is FileToOpen? I don't see it anywhere, is
that supposed to be the path to the activeworkbook? I also don't know
i
I used the following code, and it broke the links for me:

Sub BreakLinks()
Dim Awb As Workbook
Dim aLinks

Application.ScreenUpdating = False
Set Awb = ActiveWorkbook
'Get an array of the external links
aLinks = Awb.LinkSources(xlExcelLinks) 'this will return empty if
'there are not external links
'As long as the array is not empty, loop through the array and change
'the reference
If Not IsEmpty(aLinks) Then
For i = LBound(aLinks) To UBound(aLinks)
'error catching in case the external link cannot be changed
'(if the link references a worksheet
'that exists in the linked workbook, but does not exist in the
'active workbook, it will cause an
'error and the link will not be changed
On Error Resume Next
'break links
Awb.BreakLink Name:=aLinks(i), Type:=xlLinkTypeExcelLinks
On Error GoTo 0
Next i
End If
Application.ScreenUpdating = True
Erase aLinks
aLinks = Awb.LinkSources(xlExcelLinks)
If Not IsEmpty(aLinks) Then MsgBox "There are still external links in"
'this workbook"
End Sub
On Mar 12, 8:00 pm, "Chet" wrote:
Anyone know how to break external links from one spreadsheet to
another in Excel. I have used the code
ChDir "C:\Documents and Settings\fdxuser\My Documents
\Flight Loads\"
ActiveWorkbook.BreakLink Name:=FileToOpen,
Type:=xlExcelLinks
But I get an error msg and it doesn't actually break the links...

Thanks,
chet



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 88
Default Breaking excel links in code?

FileToOpen is the name of the variable for the file I was opening.
I'll try this.. Thx! Chet

On Mar 13, 6:40 am, "meatshield" wrote:
A quick question, what is FileToOpen? I don't see it anywhere, is
that supposed to be the path to the activeworkbook? I also don't know
i
I used the following code, and it broke the links for me:

Sub BreakLinks()
Dim Awb As Workbook
Dim aLinks

Application.ScreenUpdating = False
Set Awb = ActiveWorkbook
'Get an array of the external links
aLinks = Awb.LinkSources(xlExcelLinks) 'this will return empty if
'there are not external links
'As long as the array is not empty, loop through the array and change
'the reference
If Not IsEmpty(aLinks) Then
For i = LBound(aLinks) To UBound(aLinks)
'error catching in case the external link cannot be changed
'(if the link references a worksheet
'that exists in the linked workbook, but does not exist in the
'active workbook, it will cause an
'error and the link will not be changed
On Error Resume Next
'breaklinks
Awb.BreakLink Name:=aLinks(i), Type:=xlLinkTypeExcelLinks
On Error GoTo 0
Next i
End If
Application.ScreenUpdating = True
Erase aLinks
aLinks = Awb.LinkSources(xlExcelLinks)
If Not IsEmpty(aLinks) Then MsgBox "There are still external links in"
'this workbook"
End Sub
On Mar 12, 8:00 pm, "Chet" wrote:



Anyone know how tobreakexternal links from one spreadsheet to
another in Excel. I have used the code
ChDir "C:\Documents and Settings\fdxuser\My Documents
\Flight Loads\"
ActiveWorkbook.BreakLink Name:=FileToOpen,
Type:=xlExcelLinks
But I get an error msg and it doesn't actuallybreakthe links...


Thanks,
chet- Hide quoted text -


- Show quoted text -



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
Excel 07 breaking links LisaK Links and Linking in Excel 11 January 6th 10 06:11 PM
Breaking links in Excel brosull Excel Worksheet Functions 2 June 29th 09 09:38 PM
Excel 2000 breaking links awhyswoman Excel Discussion (Misc queries) 3 June 6th 07 09:04 PM
Breaking Links in Excel 2000 Nevio Excel Discussion (Misc queries) 2 August 17th 05 01:26 PM
How do I prevent my links from breaking in Excel? Excel links Excel Worksheet Functions 1 November 16th 04 05:53 PM


All times are GMT +1. The time now is 01:05 AM.

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"