type mismatch vba error

Luiza

I am trying to replace links on a spreadsheet using VBA and am getting a type mismatch error and can't figure out the reason.

Mycode:

    Dim aLinks as variant
    Dim myPath, name as String

aLinks = ActiveWorkbook.LinkSources
myPath = "C:\"
name = "test.xlsm"

    ActiveWorkbook.ChangeLink Name:=aLinks, NewName:=myPath & name, Type:=xlExcelLinks

Does anyone know the reason?

Mathieu Guindon
aLinks = ActiveWorkbook.LinkSources

The type of that would be a Variant() array.

ActiveWorkbook.ChangeLink Name:=aLinks, NewName:=myPath & name, Type:=xlExcelLinks

...and you can't coerce an array into a String.

You probably need to figure out which item in that array contains the name you want. For example:

ActiveWorkbook.ChangeLink Name:=aLinks(1), NewName:=myPath & name, Type:=xlExcelLinks

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related