Home > front end >  VBA change link at workbook
VBA change link at workbook

Time:09-29

I have the following workbook: Wb contain the macro Dest is the target workbook

Ws1=wb.worksheet(“control”)

Set Destpath = ws1.range(“D6”)

Set dest = workbook.open(destpath, updatelinks:=False) I want to change link in the dest.

Oldlink= wb.ws1.range(“D8”) Newlink=wb.ws1.range(“D12”)

Active work.changelink Name:=Oldlink, NewName:=NewLink, Type:=xlExcelLinks

After run this code,

Runtime error 1004 Method changelink of object workbook failed

Can any one help to solve it?

Regard, joe

CodePudding user response:

I'll try to help.

Is the changelink method expressed just like you posted it? The way I usually use this method is for changing between two workbooks, and the syntaxis goes like this:

ActiveWorkbook.ChangeLink "c:\excel\book1.xls", "c:\excel\book2.xls", xlExcelLinks

So the problem may be in the "Active work.c" part.

Hope this works, but if it doesn't help, maybe you can think about attacking directly the content of the cells.

Best regards,

Mike

  • Related