I have a VBA code that calls a Python code:
Sub Macro1()
Dim Ret_Val
Dim args as String
args = """F:\Asset Management\Global Equity\Better Interface new.py"""
Ret_val = Shell("C:\Users\MRay\anaconda3\python.exe" & args, vbNormalFocus)
End Sub
However, soon this code is going to be circulated around hence the username 'MRay' will change for each user. For the purposes of maintainability, we want to automate this process rather than have it be changed manually. This is what I've tried so far:
Sub Macro1()
Dim Ret_Val
Dim args As String
Dim full_id As String
Dim user_id(0 to 2) As String
user_id(0) = "C:\Users\"
user_id(1) = Application.UserName
user_id(2) = "\anaconda3\python.exe"
full_id = Join(user_id)
args = """F:\Asset Management\Global Equity\Better Interface new.py"""
Ret_val = Shell(full_id & args, vbNormalFocus)
End Sub
However, this leads to an error in the last line of Ret_val.I am really new to VBA so I just used the logic I would in Python. Any help is really appreciated:)