How to remove timestamp on a csv file

gasper21

New Member
Joined
Jan 30, 2019
Messages
20
Office Version
  1. 365
  2. 2019
  3. 2016
  4. 2013
  5. 2011
  6. 2010
  7. 2007
Hello I hope everyone is doing well. I'm looking for VBA code that will remove the timestamp on a file that is download every morning.
Sample Open in salesforce-2021-08-04-09-00-06.csv I need the name to be OpenSalesF.csv

Your assistance is greatly apricated.
Best regards
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
I guess there is only one csv file in the folder.
If so, try the following:
Update the line "C:\trabajo\Temp\" with the name of your folder.

VBA Code:
Sub renamefile()
  Dim spath As String
  Dim sfile As Variant
  
  spath = "C:\trabajo\Temp\"    'Folder where the csv file is located.
  sfile = Dir(spath & "*.csv")
  If sfile <> "" Then
    Name spath & sfile As spath & "OpenSalesF.csv"
  End If
End Sub
 
Upvote 0
Solution
I guess there is only one csv file in the folder.
If so, try the following:
Update the line "C:\trabajo\Temp\" with the name of your folder.

VBA Code:
Sub renamefile()
  Dim spath As String
  Dim sfile As Variant
 
  spath = "C:\trabajo\Temp\"    'Folder where the csv file is located.
  sfile = Dir(spath & "*.csv")
  If sfile <> "" Then
    Name spath & sfile As spath & "OpenSalesF.csv"
  End If
End Sub
Dante thank you so much for your assistance! I'm very grateful best regards (Amigo si hablas español muchisimas gracias :)) Works great!
 
Upvote 0
Donte, can you help me with this code? I'm trying to save the attachment that is on outlook and rename it to Prime Dist Rpt.csv
here is my code, this save the file however it dosen't rename the file. Can you please advise.
Gracias!!!!

Sub Attsave()
With CreateObject("outlook.application")
For Each it In .GetNamespace("Mapi").GetDefaultFolder(6).Items
For Each it1 In it.Attachments
it1.SaveAsFile "C:\Temp\" & it1.Filename 'Change the path as needed
Next
Next
End With
End Sub
 
Upvote 0
I'm trying to save the attachment that is on outlook and rename it
This code corresponds to a different requirement than the initial question in this thread. I suggest you create a new thread for each requirement.

Dante thank you so much for your assistance! I'm very grateful best regards (Amigo si hablas español muchisimas gracias :)) Works great!
Your welcome. (Encantado de ayudarte, gracias por comentar)
 
Upvote 0
Hi gasper21, You marked a post of yours as a solution, but you must mark the answer that really solved your requirement. ;)
 
Upvote 0

Forum statistics

Threads
1,214,971
Messages
6,122,521
Members
449,088
Latest member
RandomExceller01

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top