Hello!
I have an excel file with name data report y21m12d13. Every day I create a new one. For today for example will be report data y21m12d14. How I can in excel application scope to read the last file Every time and save in new excel file that in filename increase the number by one?
Thank you!
lakshman
(Ganta lakshman)
December 13, 2021, 11:10pm
2
@Stathis_Panagotas
Let’s say PrevFile is
PrevFile = "y"+Now.AddDays(-1).ToString("yy")+"m"+Now.AddDays(-1).ToString("MM")+"d"+Now.AddDays(-1).ToString("dd")
And then in Excel Application scope mention as below to read previous day file.
Directory.GetFiles("FolderPath","*"+PrevFile+"*.xlsx")(0)
Create current day file name as below.
CurrFile = "y"+Now.ToString("yy")+"m"+Now.ToString("MM")+"d"+Now.ToString("dd")
Note: Replaced mm with MM
Yoichi
(Yoichi)
December 13, 2021, 11:22pm
3
Hi,
“mm” means minute, so we should use “MM” instead of “mm” as the following.
"y"+Now.ToString("yy")+"m"+Now.ToString("MM")+"d"+Now.ToString("dd")
Regards,
1 Like
Thank you both for your support and fast reaction!
system
(system)
Closed
December 17, 2021, 4:53pm
6
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.