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 / Programming / February 2006

Tip: Looking for answers? Try searching our database.

Identifying workbooks with links to external file

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Barb Reinhardt - 28 Feb 2006 18:51 GMT
I have a list of workbooks and I want to be able to determine which ones have
a link to an external file.   All I want at this point is "YES" or "NO".    
What do I need to do programmatically to capture if a link is present in a
file.  I've got the FINDLINK utility available, but I need to know how many
documents are affected first.

Tell me what needs to be done to this

Sub LinksPresent()
Dim oWB As Workbook
Dim aWB As Workbook
Dim aWS As Worksheet

Set aWB = ActiveWorkbook
Set aWS = ActiveSheet
   Range("H1").Select
   ActiveCell.FormulaR1C1 = "Link Present"
For i = 2 To Cells(Rows.Count, "A").End(xlUp).row
       Set oWB = Workbooks.Open(Cells(i, "B"), ReadOnly = True, UpdateLinks
= False)
       Range("H" & i).Select
       ActiveCell.FormulaR1C1 = "=WHAT GOES HERE"
Next i
aWB.Save
End Sub

Thanks in advance,
Barb Reinhardt
Tom Ogilvy - 28 Feb 2006 19:14 GMT
Sub LinksPresent()
Dim oWB As Workbook
Dim aWB As Workbook
Dim aWS As Worksheet

Set aWB = ActiveWorkbook
Set aWS = ActiveSheet
   Range("H1").Select
   ActiveCell.FormulaR1C1 = "Link Present"
For i = 2 To Cells(Rows.Count, "A").End(xlUp).row
       Set oWB = Workbooks.Open(Cells(i, "B"), ReadOnly = True, UpdateLinks
             = False)
       WS.Range("H" & i).Value = iif(commandbars("Edit") _
          .Controls("Lin&ks...").Enabled,"Yes","No")
       oWB.Close SaveChanges:=False
Next i
aWB.Save
End Sub

to get a list of links

Dim alinks as Variant
aLinks = oWB.LinkSources(xlExcelLinks)
If Not IsEmpty(aLinks) Then
   For i = 1 To UBound(aLinks)
       MsgBox "Link " & i & ":" & Chr(13) & aLinks(i)
   Next i
End Ifto put them in the sheet

Dim aLinks as Variant
nLnks as Long
aLinks = oWB.LinkSources(xlExcelLinks)
nLnks = Ubound(aLinks) - lbound(alinks) + 1
WS.Range("H" & i).Resize(1,nLnks) = alinks

Signature

Regards,
Tom Ogilvy

> I have a list of workbooks and I want to be able to determine which ones have
> a link to an external file.   All I want at this point is "YES" or "NO".
[quoted text clipped - 24 lines]
> Thanks in advance,
> Barb Reinhardt
Barb Reinhardt - 28 Feb 2006 19:36 GMT
I needed to change WS to aWS to get this to work

>         WS.Range("H" & i).Value = iif(commandbars("Edit") _
>            .Controls("Lin&ks...").Enabled,"Yes","No")

> Sub LinksPresent()
> Dim oWB As Workbook
[quoted text clipped - 62 lines]
> > Thanks in advance,
> > Barb Reinhardt
Tom Ogilvy - 28 Feb 2006 21:31 GMT
Glad you were able to figure it out.

Signature

Regards,
Tom Ogilvy

> I needed to change WS to aWS to get this to work
>
[quoted text clipped - 67 lines]
> > > Thanks in advance,
> > > Barb Reinhardt
 
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.