When your macro runs while opening a project, there isn't any current open file yet, so it's impossible.
To make a macro function that gets called whenever a file becomes the current file, prefix its name with "_switchbuf_".
For example, I tested the following and it worked for me:
Make a file named something like "LinuxHelpers.e", put the following snippet in it, and then load the module (Menu -> Macro -> Load Module). I don't recommend using "vusrmacs" as the environment variable name, it's a bit generic, so below I've instead used "lnxfile" as the name.
#include "slick.sh"
void _switchbuf_SetEnvVar()
{
_str pd=absolute(p_buf_name, strip_filename(p_buf_name, 'N'));
pd=strip_filename(pd, 'D');
// bslash -> slash
pd = stranslate(pd, "/", "\\", "");
// strip leading slash
if (substr(pd, 1, 1) == "/")
pd = substr(pd, 2);
//message("pd=" pd);
set_env("lnxfile", pd);
}