Skip to main content

Get environment variable

  • July 28, 2017
  • 9 replies
  • 0 views

Hello,

 

I find how get the windows %USERPROFILE% in my script for path of the profile.

 

Can you help me plz ?


#Rumba

9 replies

Hello,

 

I find how get the windows %USERPROFILE% in my script for path of the profile.

 

Can you help me plz ?


#Rumba
Salut Patrick,

This works for me:

Sub Main
Dim wScriptObj as Object
Set wScriptObj = CreateObject( "WScript.Shell" )

Msgbox wScriptObj.ExpandEnvironmentStrings( "%USERPROFILE%" )
Set wScriptObj = Nothing
End Sub

Bon weekend,
Tom

Hello,

 

I find how get the windows %USERPROFILE% in my script for path of the profile.

 

Can you help me plz ?


#Rumba
Salut Patrick,

This works for me:

Sub Main
Dim wScriptObj as Object
Set wScriptObj = CreateObject( "WScript.Shell" )

Msgbox wScriptObj.ExpandEnvironmentStrings( "%USERPROFILE%" )
Set wScriptObj = Nothing
End Sub

Bon weekend,
Tom

Hello,

 

I find how get the windows %USERPROFILE% in my script for path of the profile.

 

Can you help me plz ?


#Rumba
Thanks Tom, I'll try lundi. But if I good understand, you created a object of script having as name WScript.Shell ?

Bon Week,

Patrick

Hello,

 

I find how get the windows %USERPROFILE% in my script for path of the profile.

 

Can you help me plz ?


#Rumba

Hi Patrick,

I'm creating a WshShell object (https://msdn.microsoft.com/fr-fr/library/aew9yb99(v=vs.84).aspx) and then using it's ExpandEnvironmentString method (https://msdn.microsoft.com/fr-fr/library/dy8116cf(v=vs.84).aspx) to get the value of the %USERPROFILE% string.

Tom


Hello,

 

I find how get the windows %USERPROFILE% in my script for path of the profile.

 

Can you help me plz ?


#Rumba

Hi Patrick,

I'm creating a WshShell object (https://msdn.microsoft.com/fr-fr/library/aew9yb99(v=vs.84).aspx) and then using it's ExpandEnvironmentString method (https://msdn.microsoft.com/fr-fr/library/dy8116cf(v=vs.84).aspx) to get the value of the %USERPROFILE% string.

Tom


Hello,

 

I find how get the windows %USERPROFILE% in my script for path of the profile.

 

Can you help me plz ?


#Rumba

Hi Patrick,

I'm creating a WshShell object (https://msdn.microsoft.com/fr-fr/library/aew9yb99(v=vs.84).aspx) and then using it's ExpandEnvironmentString method (https://msdn.microsoft.com/fr-fr/library/dy8116cf(v=vs.84).aspx) to get the value of the %USERPROFILE% string.

Tom


Hello,

 

I find how get the windows %USERPROFILE% in my script for path of the profile.

 

Can you help me plz ?


#Rumba
OK I Understand and work perfectly.

Hello,

 

I find how get the windows %USERPROFILE% in my script for path of the profile.

 

Can you help me plz ?


#Rumba
OK I Understand and work perfectly.

Hello,

 

I find how get the windows %USERPROFILE% in my script for path of the profile.

 

Can you help me plz ?


#Rumba

Hi Patrick,

I do not seem to be able to reply on the "Macro Copying Data from Excel Rumba 8.1" thread as I can't see your comment from this morning, in the Forum thread.

I won't go into it on this thread, but check out: http://www.cpearson.com/Excel/FindAll.aspx. If you are still having problems please open a new thread on the forum. 

Note: I find this website invaluable if I'm doing anything tricky in Excel, it's full on interesting code samples.

Tom