VBA code for updating one specific linked file

DutchKevin

Board Regular
Joined
Apr 13, 2011
Messages
133
Office Version
  1. 365
Platform
  1. Windows
Hello,
I'm looking for a way to refresh the "ABC file" that my workbook is linked to.
The new ABC file will always be in the same folder and have specific naming convention. Like "ABC Week2013_03.xlsm"
My workbook also has links to other files, but these remain unchanged.
So far i've been able to come up with:
Code:
            Sub UpdateABC()
            Set ThisBook = ActiveWorkbook
            ChDrive "S:\"
            ChDir "S:\ABC files\"
            LatestDTR = Application.GetOpenFilename(Title:="Please choose the most recent ABC file", FileFilter:="XLS Files *.xls* (*.xls*),")
            If LatestABC = False Then
                MsgBox "No file specified.", vbExclamation, "Error"
            Else
            'Workbooks.Open Filename:=LatestABC 'for checking the file if needed
            End If
            ThisBook.Activate
            ActiveWorkbook.ChangeLink "[COLOR=#ff0000][I]I need a way to get the current linked ABC file name here[/I][/COLOR]", LatestABC, xlExcelLinks
            'ActiveWorkbook.UpdateRemoteReferences = True

            End Sub
Can anyone suggest a way to make the current ABC file name into a variable? It has always a certain filenaming format ("ABC Week2013_03.xlsm") so it must be quite easy to filter out of the linked files list. But How??

Thanks in advance

Kevin
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
You can loop through the LinkSources of Type xlExcelLinks and use Instr to check that the name contains eg "ABC Week". If it does that's the current link.
 
Upvote 0

Forum statistics

Threads
1,223,277
Messages
6,171,148
Members
452,382
Latest member
RonChand

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top