Assign Variable Value with External Function

ERLoft

Board Regular
Joined
Feb 24, 2006
Messages
195
My company changed from a local server to OneDrive this week, breaking a whole bunch of my macros that rely on the actual filepath rather than a URL.

After some research, I'm planning to utilize a Function created by Guido Witt-Dörring that solves the issue. However, there are hundreds of workbooks that would need to be updated with this Function and only 3 users who need to use it. I want to place the function in those 3 Personal.xlsb files and call the function from the workbooks that need it.

This works fine if the Function is in the active workbook:
VBA Code:
Test = GetLocalPath(ActiveWorkbook.Path)

But doesn't work if I'm trying to do the same thing from the Personal workbook:
Code:
Test = Personal.xlsb!GetLocalPath(ActiveWorkbook.Path)

I can also use application.run to call the Function without issues:
Code:
Application.Run "Personal.xlsb!GetLocalPath", (ActiveWorkbook.Path)

But can't use that to assign the value to anything:
Code:
Test = Application.Run "Personal.xlsb!GetLocalPath", (ActiveWorkbook.Path)

So, what am I missing here? How can I assign the value of GetLocalPath to a variable whilst running it from Personal.xlsb?

Thanks!
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
Got it. Posting for anyone searching in the future. Was missing parentheses in the last example. Should have been:
VBA Code:
Test = Application.Run("Personal.xlsb!GetLocalPath", (ActiveWorkbook.Path))
 
Upvote 0

Forum statistics

Threads
1,224,600
Messages
6,179,836
Members
452,947
Latest member
Gerry_F

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top