Home » excel » excel – VBA Workbook Address

excel – VBA Workbook Address

Posted by: admin April 23, 2020 Leave a comment

Questions:

I am writing a macro, workbook MACRO, that has to open another workbook, lets call it OPEN.

The problem is the workbooks OPEN and MACRO are on the net and the OPEN‘s address is up to the person who runs the macro.

I mean, if I run the macro the address is:

X:\Destkop\OPEN.xlsm

but, for example, if the macro is run by another person, the address could change:

Y:\Destkop\OPEn.xlsm

so for the macro it is imposible to open the workbook OPEN and it doesn’t run the code.

To get the address I use the following code:

activeworkbook.fullname 

but the problem is that code will return the address of the OPEN in my computer not on the “net”.

Is there anyway to know/get the address of any workbook placed on the net???

How to&Answers:

Instead of using the mapped drive letter, use the UNC address. X:\ and Y:\ are most likely different aliases (for want of a better term) to the same place which can also be expressed in UNC form as

\ServerName\SharedFolder\

So the full path would be \\ServerName\SharedFolder\Desktop\Open.xlsm

You should be able to use that in the command to open the workbook and it will no longer matter which drive letter they have the share mapped to or indeed whether they have it mapped at all, as long as they have access to it.