+ Reply to Thread
Results 1 to 4 of 4

Rename file

Hybrid View

alan101 Rename file 12-06-2017, 11:14 PM
Logit Re: Rename file 12-06-2017, 11:47 PM
alan101 Re: Rename file 12-07-2017, 12:34 AM
Logit Re: Rename file 12-07-2017, 12:58 AM
  1. #1
    Registered User
    Join Date
    12-06-2017
    Location
    belfast
    MS-Off Ver
    10
    Posts
    2

    Rename file

    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".

  2. #2
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,444

    Re: Rename file

    .
    You can use the command ENVIRON("username") as show below :

    
    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
    So .. instead of : "c:\Users\john_doe\AppData\Local\Temp\file.txt" you would use "c:\Users\Environ("username")\AppData\Local\Temp\file.txt"

  3. #3
    Registered User
    Join Date
    12-06-2017
    Location
    belfast
    MS-Off Ver
    10
    Posts
    2

    Thumbs up Re: Rename file

    That worked. Thank you!

  4. #4
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,444

    Re: Rename file

    You are welcome.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. My File Rename Macro Always Doesn't Rename the Last Three files in the list
    By Enright in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-02-2016, 03:46 PM
  2. Replies: 0
    Last Post: 01-21-2014, 10:52 AM
  3. Excel VBA find and replace string in non text file and rename file
    By razzack in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-01-2013, 02:43 PM
  4. Replies: 1
    Last Post: 04-20-2013, 10:30 AM
  5. [SOLVED] import every file in the folder and rename sheet to the imported file name
    By vivek_work in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 09-04-2012, 02:46 PM
  6. Rename file and Create new file with new folder with macro/vba
    By rizki96 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-11-2011, 08:01 AM
  7. File Saved As Read Only? Can't Delete / Rename File
    By Kolin in forum Excel General
    Replies: 3
    Last Post: 11-02-2010, 12:01 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1