Solved

Changelink doe not work

Posted on 2011-03-22
1
384 Views
Last Modified: 2012-06-27
Hi,

I use the code below to change the links with other sheets.

    NewLink = Application.GetOpenFilename("Excel-files,*.xls", 1, "Select File", , False)
    OldLink = ws.Range("B2").Value
    Set ws = ThisWorkbook.Worksheets("Sheet1")
    ThisWorkbook.Changelink Name:=OldLink, NewName:=NewLink, Type:=xlExcelLinks
    Set ws = ThisWorkbook.Worksheets("Sheet2")
    ThisWorkbook.Changelink Name:=OldLink, NewName:=NewLink, Type:=xlExcelLinks

For Sheet1 it works, but not for Sheet2.
What's wrong?

Tx
0
Comment
Question by:sonmic
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 33

Accepted Solution

by:
jppinto earned 500 total points
ID: 35187878
Before this line:

OldLink = ws.Range("B2").Value

Do you have ws set already? You're setting Set ws = ThisWorkbook.Worksheets("Sheet1") after this OldLink = ws.Range("B2").Value...

You should do like this:

NewLink = Application.GetOpenFilename("Excel-files,*.xls", 1, "Select File", , False)
Set ws = ThisWorkbook.Worksheets("Sheet1")
OldLink = ws.Range("B2").Value
ThisWorkbook.Changelink Name:=OldLink, NewName:=NewLink, Type:=xlExcelLinks
Set ws = ThisWorkbook.Worksheets("Sheet2")
OldLink = ws.Range("B2").Value
ThisWorkbook.Changelink Name:=OldLink, NewName:=NewLink, Type:=xlExcelLinks

This is how it makes sense to me...

jppinto
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
Excel can be a tricky bit of software to get your head around. Whilst you’ll be able to eventually get to grips with the basic understanding of how to get by, there are a few Excel tips that not everybody will even know about let alone know how to d…
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question