Excel VBA change (or edit ) links Macro

In summary, you want to change the link so that it points to your "local" directory instead of the "AppData\Roaming" directory.
  • #1
DoubleHubble
9
0
Excel VBA change (or "edit") links Macro

I have a Excel spreadsheet that has several links in it which I need to change to a different computer/user. The links are all the same and to change the source I have to go to "Edit Links" and manually change the location to the specific location on my computer.

For example my link is: 'C:\Users\My Name\AppData\Roaming\Microsoft\AddIns'

What is the quickest way to change/automate this link upon opening this file from a different user's directory (to say: 'C:\Users\Any Name\AppData\Roaming\Microsoft\AddIns')?

So not only do I need to change the link, but I need to change it to the current user's name -- which could be anyone.

To summarize I want the cells' values to change from:
='C:\Users\My Name\AppData\Roaming\Microsoft\AddIns\Addin.xla'!ADDFUNCTION(S3,$B$2)

to:
='C:\Users\Any Name\AppData\Roaming\Microsoft\AddIns\Addin.xla'!ADDFUNCTION(S3,$B$2)

without the user (Any Name) having to do anything -- ADDFUNCTION is a simple/dummy addin function that I made to add two cells together for purposes of answering this question.
 
Physics news on Phys.org
  • #2


I don't know excel that good (i use MATLAB for excel-type stuff) but I'll give two suggestions in hopes that Excel can perform at least one of them:

1. relative directory. If Excel allows, instead of doing the absolute directory, C:\stuff\mydir you can reference the relative directory to the application's "local" directory: .\mydir

2. if statement and a computer function. If Excel has a function that reports some identity about the competer, you could run that test and choose the directory based on the computer identity.

The syntax and terminology might not be the same in Excel, but hopefully you can find something in help or google.
 
  • #3


You can try this. Cell D5 will be the text string that you want, DoubleHubble.

In cell A5: C:\Users\My Name\AppData\Roaming\Microsoft\AddIns\Addin.xla'!A DDFUNCTION(S3,$B$2)

Cell B5: =LEFT(A5,9)

Cell C4: 200 [or some integer larger than the largest text string you expect to have]
Cell C5: =MID(A5,17,C$4)

Cell D4: Any Name
Cell D5: =CONCATENATE(B5,D$4,C5)
 

What is Excel VBA change (or edit) links Macro?

Excel VBA change (or edit) links Macro is a programming feature in Microsoft Excel that allows users to automate the process of changing or editing links between different Excel files. This can be useful for updating data or formulas in multiple files at once.

How do I create a change (or edit) links Macro in Excel VBA?

To create a change (or edit) links Macro in Excel VBA, open the Visual Basic Editor by pressing Alt+F11. Then, insert a new module and write the VBA code to define the links you want to change or edit. You can use the ChangeLink or EditLink methods to specify the old and new file paths.

Can I use Excel VBA change (or edit) links Macro to update links automatically?

Yes, you can use Excel VBA change (or edit) links Macro to update links automatically. You can use the Workbook_ChangeLink or Workbook_SheetChangeLink events to trigger the Macro whenever a link is updated in the workbook.

What are the advantages of using Excel VBA change (or edit) links Macro?

One of the main advantages of using Excel VBA change (or edit) links Macro is that it saves time and effort by automating the process of updating links between Excel files. It also reduces the risk of errors that may occur when manually changing or editing links.

Are there any limitations to using Excel VBA change (or edit) links Macro?

Yes, there are some limitations to using Excel VBA change (or edit) links Macro. It only works for links between Excel files and cannot be used for links to external sources such as databases or websites. Additionally, it may not work with certain complex or unsupported file formats.

Similar threads

  • Computing and Technology
Replies
10
Views
1K
Replies
27
Views
2K
  • Computing and Technology
Replies
13
Views
961
  • Calculus and Beyond Homework Help
Replies
8
Views
3K
  • Programming and Computer Science
Replies
7
Views
483
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
3K
  • Programming and Computer Science
Replies
4
Views
340
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
3K
  • Programming and Computer Science
Replies
4
Views
2K
  • Computing and Technology
Replies
20
Views
706
Back
Top