AnsweredAssumed Answered

EPDM task, save to folder based on username

Question asked by Chris Manger on Jan 27, 2015
Latest reply on Jan 30, 2015 by Chris Manger

I am looking for a way to save converted files to a specific folder based on which user is running the task.

 

Ex.  Task name - Convert to PDF

User 'Harry' runs the 'Convert to PDF' task.  The drawing is converted and saved to 'M:\PDFS\Harry'.


So the Output File Details would look something like

M:\PDFS\<USERNAME>

 

I started to play around with 'Advanced Scripting Options' but I cant seem to figure out how to create a custom variable.  I use the code below is a couple of my SolidWorks macro (VBA), which gets the username of the logged in user.


Any suggestions would be appreciated.

 

Thank you.

 

Function UserName() As String

    Dim myShell

    Dim content

    Dim value

  

    Set myShell = CreateObject("WScript.Shell")

  

    For Each value In myShell.Environment("PROCESS")

        content = Split(value, "=")

        If content(0) = "USERNAME" Then UserName = content(1)

    Next

  

    'If UserName = "" Then UserName = "-"

  

    Set myShell = Nothing

End Function

Outcomes