1

I wanted to set a new Environment Variables Name "Sample" and Value "E:\Sample" onto user variables not on system variables.

How do I do this using VBA excel?

Thank you and kind regards,

braX
  • 11,506
  • 5
  • 20
  • 33
vague guy
  • 29
  • 4

1 Answers1

1
Sub addEnvironVariables()

    Dim WSS: Set WSS = CreateObject("WScript.Shell")
    Set System = WSS.Environment("User")
    System.Item("Sample") = System.Item("Sample") & ";C:\Sample"

End Sub

Found it on youtube

Harun24hr
  • 30,391
  • 4
  • 21
  • 36
vague guy
  • 29
  • 4
  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jan 20 '22 at 00:27