I need to rename a file,
I can use this on my local machine - Name "c:\Users\john_doe\AppData\Local\Temp\file.txt" As "c:\Users\john_doe\AppData\Local\Temp\newfile.rtf"
Can wildcards be use when I don't know the username "john_doe".
I need to rename a file,
I can use this on my local machine - Name "c:\Users\john_doe\AppData\Local\Temp\file.txt" As "c:\Users\john_doe\AppData\Local\Temp\newfile.rtf"
Can wildcards be use when I don't know the username "john_doe".
.
You can use the command ENVIRON("username") as show below :
So .. instead of : "c:\Users\john_doe\AppData\Local\Temp\file.txt" you would use "c:\Users\Environ("username")\AppData\Local\Temp\file.txt"![]()
Sub GetComputerUserName() Dim ComputerName, UserName As String 'Getting computer name ComputerName = Environ("computername") 'Getting user name UserName = Environ("username") 'Assigning value to cell C10 and C11 Range("C10").Value = ComputerName Range("C11").Value = UserName End Sub
That worked. Thank you!
You are welcome.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks