Hello Everyone
How can we save the file that is open in the Current Month Folder?
The Month Folder is already Created but how does the bot identify the Current Month Folder and Save the File that is Open in that Folder Only
Hello Everyone
How can we save the file that is open in the Current Month Folder?
The Month Folder is already Created but how does the bot identify the Current Month Folder and Save the File that is Open in that Folder Only
Hi there @anmita,
I hope you are well!
You can generate the month at runtime using the below:
Assign - strCurrentMonth = DateTime.Today.Month.ToString()
If run today, this would have a value of 5
, given we are in May.
Should you need to format it a particular way, you can also do the below:
Assign - strCurrentMonth = DateTime.Today.ToString("MM-yyyy")
Which will return the result 05-2022
.
Ultimately, you need to take this dynamically generated value and add it to your folder path - For example:
Assign - strMonthFolderPath = Path.Combine("C:\Users\Mr_JDavey\Documents\Months", strMonth)
This will produce a path equal to (using the latest date example):
C:\Users\Mr_JDavey\Documents\Months\05-2022
Please let me know if you have any questions.
Thanks once again for your support,
Josh
Hi @Mr_JDavey ,
Actually my Question is that
For Example : I have a Folder in C Drive as below for the Month and Year that is already created
And the Excel File that is currently open that I want to Save inside the month which at Present is May. Therefore 05 inside which the File should save as abc.xlsx
2022–>05–>Abc.xlsx
Thanks For the Quick Response:)
Hi again @anmita,
Apologies, I misunderstood.
You can get the current year/month values using:
Assign - strYear = DateTime.Today.Year.ToString("yyyy")
Assign - strMonth = DateTime.Today.Month.ToString("MM")
Then, you can create the path using:
Assign - strDynamicFilePath = Path.Combine("C:\Users\Mr_JDavey\", strYear, strMonth, "Abc.xlsx")
The output will be:
C:\Users\Mr_JDavey\2022\05\Abc.xlsx
Always happy to help!
Thanks once again,
Josh
Hi @anmita,
@Mr_JDavey shows you how to create this file path. You can position the file by doing now.Month.ToString while saving it.
Regards,
MY
Thanks Once Again @Mr_JDavey
Thanks @muhammedyuzuak