Hi,
You have to iterate through the files inside the folder and inside foreach use Excel application scope activity pass that item in the “workbookpath” which dynamically choose the file one after another .
If you want to itereat through only today’s file follow my previous post else u can set the counter=1 in the foreah and exit after that.
inside sequence if you will use your Excel application Scope and if you will pass the item variable it will replace the absolute path of that file and excel application scope will check that path and if it exists there then it will open that excel visible if you have checked visible chekcbox if not then background. same it will happen will all Excel files exists in that particular directory on each iteration.
Hello - having a similar issue here. We have a two step process - one to extract an Excel file from SAP and one to open it and manipulate it. The Excel file save in SAP is fine. At the beginning of that sequence we created a variable named today and assigned it to a current date .NET description – it works FINE and we use the variable in the Excel file name when we save it – for example, if the file is save on 24 June 2017 the filename is TheReport24062017.xslx. The variable for the short date is called tdy.
In the Excel Application scope that immediately follows, we want to specify the file path as
“C:\SOTC\Reports\TheReport” + tdy + “.xlsx” . The file seems to be recognized and the first activity is to read range and the output is reportDT. That seems to be fine too. But when we try to delete column F using the Delete Column activity. It barks at us to say “Delete Column: The table does not exist”. Searching further, we discover that the Excel Application Scope is not finding the real file ---- it is instead creating a blank Excel file named TheReport.xslx and that is what is read by the Read Range activity.
Questions:
How do we get the Excel Application Scope to find the right file when the file name contains a date that changes every day?
When we use Delete Column, in the Table field we enter the data table name - in our case, reportDT - but it makes us add .ToString and then when we enter “F” in the column name we get the Table not found error. HELP!
String[ ] return_Value = Directory.GetFiles(“F:\Test",”*.xlsx") // This will return you only the *.xlsx files from a particular folder path only.
Directory.GetFiles(“”,“”)
path
Type: System.String
The relative or absolute path to the directory to search. This string is not case-sensitive.
searchPattern
Type: System.String
The search string to match against the names of files in path. This parameter can contain a combination of valid literal path and wildcard (* and ?) characters (see Remarks), but doesn't support regular expressions.
Return Value
Type: System.String
An array of the full names (including paths) for the files in the specified directory that match the specified search pattern, or an empty array if no files are found.
First i am checking is there any same file present in the system if there is any file i am deleting that file but it’s also a hard coding because for this i need to check the file name , i want to remove all the hard hard codes ,do u have any solution ?
why u wanna search a whole system for one file? their will be chances like there can mulitple folders and under those you will have sample.xlsx … so why you choose one particular path for all your project needs like Input,Output, Download their you can check easily.
and regarding hardcode path you can get absolute path by using path Class.