VBA Changelink method returns error when variables are used.

ash.mak

New Member
Joined
Jun 29, 2010
Messages
41
Hi ALL.

I am getting method failed error when running the following;

ActiveWorkbook.ChangeLink OldLink, NewLink, xlExcelLinks

OldLink = "D:\Ash\Planning\Forecast20130601.xls"
NewLink= "C:\Temp\Planning\Forecast20130815.xls"

OldLink and NewLink are string variables. They compile OK but error returned on runtime.

this is part of macro, I use in a template. I just copy this template in the any foldery with my forecast file and when opening this template the only link in the template should search for the forecast file in current directory and change links automatically to the forecast file in this folder. Hope I am clear and not confusing.
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
Define the strings before using them in the .ChangeLink method.

Code:
OldLink = "D:\Ash\Planning\Forecast20130601.xls"
NewLink = "C:\Temp\Planning\Forecast20130815.xls"
    
ActiveWorkbook.ChangeLink OldLink, NewLink, xlExcelLinks
 
Upvote 0

Forum statistics

Threads
1,216,756
Messages
6,132,529
Members
449,733
Latest member
Nameless_

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