Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 10-15-2015, 12:26 AM
Officer_Bierschnitt Officer_Bierschnitt is offline Links to other files Windows 7 64bit Links to other files Office 2013
Advanced Beginner
Links to other files
 
Join Date: Oct 2015
Posts: 87
Officer_Bierschnitt is on a distinguished road
Thumbs up Links to other files

Hi,

I know there is a possibility in Excel to display the paths and names of all files which this particular one links to.
My question is, is there any method - easier than typing it off - to get this info onto another sheet?

Background: We have a spiderweb of Excel_files on_site and no one knows what are the "right and left neighbours" of his/her Excel_file, so no one knows what he/she might break by introducing some change in his/her file.

Now, me and a colleague have developed a docu_sheet with a responsible for each list, a list of files that particular one draws from and the files that draw from this.
I now want to have IT make this into a template_file and drop it into the directories of each and every PC and laptop on_site so this sheet will become a part of each new list generated.


But expecting the employees to type the info from this dialog onto that new sheet could well be expected from them, but it is just more than can reasonably be expected to happen ... so I would like to offer some easier and more convenient way of getting that info there.

Thanks a lot!
Best regards,

Officer_Bierschnitt
Reply With Quote
  #2  
Old 10-18-2015, 01:17 AM
macropod's Avatar
macropod macropod is offline Links to other files Windows 7 64bit Links to other files Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,363
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

It's easy-enough to extract a report of all files a given workbook links to, but no workbook contains any information about what other files link to it. Furthermore, it's not only Excel files you need to consider; Word and PowerPoint files, for example, might contain links to an Excel file.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 10-19-2015, 02:04 AM
Officer_Bierschnitt Officer_Bierschnitt is offline Links to other files Windows 7 64bit Links to other files Office 2013
Advanced Beginner
Links to other files
 
Join Date: Oct 2015
Posts: 87
Officer_Bierschnitt is on a distinguished road
Thumbs up

Hi,

strange - when I try to quote your post, the system tells me I'm not logged in, even though I am. Posting a reply is obviously possible, though.

Well - would you mind telling me how to extract such a report? Thanks a lot!

(it is very important to provide a rel. easy way of getting that info on that sheet, else it isn't realistic to believe people are going to do it ...)

I'm aware that an Excel_file cannot "know" which other files, Excel or whatever, use its data. That information has to be filled in to the docu_sheet I have developed "backwards" - whenever somebody makes a link to an earlier file, he/she should fill in that info in that earlier file.


Best regards,

Officer_Bierschnitt
Reply With Quote
  #4  
Old 10-19-2015, 02:56 AM
macropod's Avatar
macropod macropod is offline Links to other files Windows 7 64bit Links to other files Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,363
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

For example:
Code:
Sub Demo()
Dim StrLnks As String, i As Long, aLnks
With ActiveWorkbook
  On Error Resume Next
  aLnks = .LinkSources(xlExcelLinks)
  StrLnks = StrLnks & "Excel Links: "
  For i = 1 To UBound(aLnks)
    StrLnks = StrLnks & vbCr & aLnks(i)
  Next i
  aLnks = .LinkSources(xlOLELinks)
  StrLnks = StrLnks & vbCr & vbCr & "OLE Links: "
  For i = 1 To UBound(aLnks)
    StrLnks = StrLnks & vbCr & aLnks(i)
  Next i
End With
MsgBox StrLnks
End Sub
As coded, the above macro tests the active workbook and simply outputs what it finds to a message box. Getting the data onto a worksheet or output to a text file would be quite easy, but you obviously wouldn't want it overwriting your worksheet data! With some extra code, the process could be made to run against all Excel files in a folder and send the output, including each linking file's name, to a new file (e.g. Excel workbook/text file/Word document).
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #5  
Old 10-19-2015, 05:26 AM
Officer_Bierschnitt Officer_Bierschnitt is offline Links to other files Windows 7 64bit Links to other files Office 2013
Advanced Beginner
Links to other files
 
Join Date: Oct 2015
Posts: 87
Officer_Bierschnitt is on a distinguished road
Default

Hi macropod,

thanks again!
That "it would be quite easy to ..." is great to hear/read when you don't know how. You also said this whole thing was easy. Well, it is - once you know the code.
Like Columbus' egg, everything is easy to the one who knows how to do it. Building a house or knitting a scarf is also easy, still ...
Running that macro over all Excel_files is unfortunately not an option, IT would never allow it - but I can use it on one file at a time all right.
Well, I'll find out.

Thanks a lot!

Best regards,

Officer_Bierschnitt
Reply With Quote
  #6  
Old 10-19-2015, 07:40 AM
Officer_Bierschnitt Officer_Bierschnitt is offline Links to other files Windows 7 64bit Links to other files Office 2013
Advanced Beginner
Links to other files
 
Join Date: Oct 2015
Posts: 87
Officer_Bierschnitt is on a distinguished road
Default

Okay,

with some help of a knowledgeable colleague I have now adapted the code so that all the linked worksheets are written, one per line, into the docu_sheet.
Now I can take one workbook at a time, insert a VBA_module with this code, run it and remove it again afterwards. A bit tedious, but the easiest way we have.

Best regards,

Officer_Bierschnitt
Reply With Quote
  #7  
Old 10-19-2015, 02:52 PM
macropod's Avatar
macropod macropod is offline Links to other files Windows 7 64bit Links to other files Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,363
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Quote:
Originally Posted by Officer_Bierschnitt View Post
Running that macro over all Excel_files is unfortunately not an option, IT would never allow it - but I can use it on one file at a time all right.
The following macro allows you to select a folder and extract the link data for all Excel files in that folder.
Code:
Sub Demo()
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Dim strFolder As String, strFile As String, aLnks
Dim xlWkBk As Workbook, xlWkSht As Worksheet, i As Long, j As Long
Set xlWkSht = ThisWorkbook.Sheets(1)
strFolder = GetFolder
If strFolder = "" Then Exit Sub
j = xlWkSht.UsedRange.Cells.SpecialCells(xlCellTypeLastCell).Row + 1
strFile = Dir(strFolder & "\*.xls", vbNormal)
While strFile <> ""
  If strFolder & "\" & strFile <> ThisWorkbook.FullName Then
    Set xlWkBk = Workbooks.Open(Filename:=strFolder & "\" & strFile, AddToMRU:=False, ReadOnly:=True)
    j = j + 1
    With xlWkBk
      xlWkSht.Cells(j, 1).Value = .FullName
      On Error Resume Next
      aLnks = .LinkSources(xlExcelLinks)
      For i = 1 To UBound(aLnks)
        j = j + 1
        xlWkSht.Cells(j, 2).Value = aLnks(i)
      Next i
      aLnks = .LinkSources(xlOLELinks)
      For i = 1 To UBound(aLnks)
        j = j + 1
        xlWkSht.Cells(j, 2).Value = aLnks(i)
      Next i
      j = j + 1
      .Close SaveChanges:=False
    End With
  End If
  strFile = Dir()
Wend
Set xlWkBk = Nothing
Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = True
End Sub
 
Function GetFolder() As String
Dim oFolder As Object
GetFolder = ""
Set oFolder = CreateObject("Shell.Application").BrowseForFolder(0, "Choose a folder", 0)
If (Not oFolder Is Nothing) Then GetFolder = oFolder.Items.Item.Path
Set oFolder = Nothing
End Function
You'll probably find it takes only a few minutes to process even a very large folder.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Links to other files Word 2007 Edit Links to Files ptmuldoon Word 7 11-30-2014 04:09 PM
How to copy linked Excel and Word files and retain links ashleynpeters1 Word 1 05-30-2013 02:25 PM
How to break Links to FIles in visual basic? Asinkan PowerPoint 0 11-15-2012 03:08 AM
Break Links to Files automaticaly Asinkan PowerPoint 0 11-14-2012 08:15 AM
Links between files to bookmarks in PDF spud098 Word 0 07-14-2010 01:11 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 11:33 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft