Sorry for the long answer, I just wanted to make sure I explained it pretty well.
From this page (Anatomy of the declaration statement) we read that
The lib keyword indicates which DLL contains this function. Note that the dll name is contained in the string in the ad expression. (highlighted by me)
From an experiment, VBE scolds me if I try to give anything other than a string constant.
The only work I know of is overwriting the string constant at runtime.
Here is an example of how this can be done: let them say that your delaration statement is located in Module1 in your current project and that you intentionally wrote an ad in this format at the top of your module:
Private Declare Sub sharedLibPassString CDecl Lib _ "/Users/myUserName/Library/Application Support/myCompanyName/MySharedLib.dylib" _ Alias "PassString" (ByVal aString As String)
You can access this module through code through this (for this, permissions for VBA in the trust center specified in the "Developer macro settings" section are required):
Dim myModule set myModule = ActivePresentation.VBProject.VBComponents("Module1").CodeModule
Once you have purchased CodeModule, you can directly replace the second line:
myModule.ReplaceLine 2, Environ("HOME") & " _"
Mission accomplished!
If you do this, you will need to update the path before trying to call your declared under. There must be a performance gap that allows VBA to recognize changes. In addition, you cannot change the code in break mode.
Now, if I did this, I would like me to replace the correct line so as not to break the code. You can check the contents of the second string by calling this myModule.Lines(2,1) , which will return the string value of the string.
However, here is a more robust solution that will find the correct string and then replace it (assuming myModule is already defined as above):
Dim SL As Long, EL As Long, SC As Long, EC As Long Dim Found As Boolean SL = 1 ' Start on line 1 SC = 1 ' Start on Column 1 EL = 99999 ' Search until the 99999th line EC = 999 ' Search until the 999th column With myModule 'If found, the correct line will be be placed in the variable SL 'Broke search string into two pieces so that I won't accidentally find it. Found = .Find("/Users/myUserName/Library/Application Support/myCompanyName/" & _ "MySharedLib.dylib", SL, SC, EL, EC, True, False, False) If Found = True Then 'Replace the line with the line you want, second paramater should be a string of the value. .ReplaceLine SL, Environ("HOME") & " _" End If End With