+ Reply to Thread
Results 1 to 7 of 7

External file link

  1. #1
    Registered User
    Join Date
    12-08-2005
    Posts
    84

    External file link

    Hiya guys and gals

    I have a problem.

    I have a work sheet that references 10 external workbooks.

    What i need to do is for my worksheet to look for the external workbook in the same folder as the main workbook is stored in instead of having the full C:\Documents and Settings\James\Excel\

    As i have to create multiple documents and email them to others they may chose to save them in alternate locations. If they do this when the workbooks are opened they will not be able to recognise the links.

    I hope i have explained myself correctly.

    Regards

    James

  2. #2

    Re: External file link

    Yes, I understood your problem. The only way to solve it is to put
    all the Worksheets in the same Workbook because there's no way to
    "bundle" more than one Workbook, but you can "bundle" many Worksheets
    in one Workbook.

    ed


  3. #3
    JMB
    Guest

    RE: External file link

    Maybe you could try a Workbook Open Event handler to change the links. Paste
    the code into the thisworkbook module in the VB Editor (Alt+F11, View/Project
    Explorer, double click on the thisworkbook module of your spreadsheet to open
    up a code window). Be sure to back up your work.

    Private Sub Workbook_Open()
    Dim varLinks As Variant
    Dim i As Long
    Dim strFName As String

    varLinks = ThisWorkbook.LinkSources(xlExcelLinks)

    If Not IsEmpty(varLinks) Then
    For i = LBound(varLinks) To UBound(varLinks)
    With ThisWorkbook
    strFName = Left(.FullName, _
    InStrRev(.FullName, "\", -1, _
    vbTextCompare)) & Right(varLinks(i), _
    Len(varLinks(i)) - InStrRev(varLinks(i), _
    "\", -1, vbTextCompare))

    If Dir(strFName) <> "" Then
    .ChangeLink Name:=varLinks(i), _
    NewName:=strFName, Type:=xlExcelLinks
    Else: MsgBox "File " & strFName & "Not Found"
    End If
    End With
    Next i
    End If
    End Sub


    "superkopite" wrote:

    >
    > Hiya guys and gals
    >
    > I have a problem.
    >
    > I have a work sheet that references 10 external workbooks.
    >
    > What i need to do is for my worksheet to look for the external workbook
    > in the same folder as the main workbook is stored in instead of having
    > the full C:\Documents and Settings\James\Excel\
    >
    > As i have to create multiple documents and email them to others they
    > may chose to save them in alternate locations. If they do this when the
    > workbooks are opened they will not be able to recognise the links.
    >
    > I hope i have explained myself correctly.
    >
    > Regards
    >
    > James
    >
    >
    > --
    > superkopite
    > ------------------------------------------------------------------------
    > superkopite's Profile: http://www.excelforum.com/member.php...o&userid=29496
    > View this thread: http://www.excelforum.com/showthread...hreadid=535343
    >
    >


  4. #4
    Registered User
    Join Date
    12-08-2005
    Posts
    84
    thanks guys

    I will try these out when i get to work and let you know

    King Regards

    James

  5. #5
    Registered User
    Join Date
    12-08-2005
    Posts
    84
    thanks guys

    I will try these out when i get to work and let you know

    King Regards

    James

  6. #6
    Forum Expert
    Join Date
    01-03-2006
    Location
    Waikato, New Zealand
    MS-Off Ver
    2010 @ work & 2007 @ home
    Posts
    2,243
    Hi,
    Personally, I'd use an approach like the one suggested by JMB, but if you have users who disable macros when opening files then another (potentially v slow to implement but) possible approach is to use the indirect function instead of direct links.

    To do this you'd need a reference cell that provides the correct directory & then convert all your direct formulae to indirect functions which grab the value from the reference cell.

    Rob Brockett
    NZ
    Always learning & the best way to learn is to experience...

  7. #7
    JMB
    Guest

    Re: External file link

    Good point. Sometimes I put a message on the main sheet that macros must be
    enabled to use the workbook properly. Or, he could put a message that macros
    are disabled, and have the workbook open code change it to say macros are
    enabled so the user will have some idea of what's going on.

    I think one consideration with INDIRECT is if the OP makes changes to the
    source workbooks (cut/paste or insert/delete rows), the links in the target
    workbook will not automatically change to reflect the new cell addresses,
    unlike using a direct link (assuming both the soure and target workbook are
    open). If I used INDIRECT, I would consider leaving the direct links in my
    copy, then maybe use a macro to change the formulae in the externally linked
    cells to use INDIRECT and distribute that copy to the users.



    "broro183" wrote:

    >
    > Hi,
    > Personally, I'd use an approach like the one suggested by JMB, but if
    > you have users who disable macros when opening files then another
    > (potentially v slow to implement but) possible approach is to use the
    > indirect function instead of direct links.
    >
    > To do this you'd need a reference cell that provides the correct
    > directory & then convert all your direct formulae to indirect functions
    > which grab the value from the reference cell.
    >
    > Rob Brockett
    > NZ
    > Always learning & the best way to learn is to experience...
    >
    >
    > --
    > broro183
    > ------------------------------------------------------------------------
    > broro183's Profile: http://www.excelforum.com/member.php...o&userid=30068
    > View this thread: http://www.excelforum.com/showthread...hreadid=535343
    >
    >


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1