How to open a file with variable file-name?


#1

Hi
I would like to know if it is possible to store a file name in a variable (it can be PDF, Excel, CSV etc) and open it for reading?

Means suppose a PDF file is generated with today’s date attached to its file name (say Document_08_16_2017.PDF).
Now suppose if I am able to get that file name generated through .NET script, how will I pass this dynamic file name to Read PDF Text activity?


#2

Hi,
Before getting name of file you must locate the file path then you could pass path.combine(“path”,“filename”) in the ReadPDFText Activity.


#3

Hi, I have a similar question - I have a variable created with a value of report name plus current date. In an excel scope, I want to open this report everyday. I want to use the variable as the file name to open. I have tried several variations but can not get it to open.

Variable: fileName is a variable with a value of "Report Name " + DateTime.Now.ToString(“MM-dd-yyyy”) + “.xls”

Excel Scope: "C:\Users\Documents\UiPath\ +“fileName”


#4

Hi,
Are you getting any error?
try below path.
“C:\Users\Documents\UiPath” +fileName


#5

Thanks - I tried and still does not open - no error - just opens a blank worksheet in excel.


#6

Should add - I have it as an argument not a variable.


#7

I don’t think so argument makes any difference here .Because as you mentioned its opening blank worksheet that bit wired isn’t it :thinking:
Are you sure there is file available in the following path containing data (having same file name?)


#8

I really think it is my Excel. Today it opened the file, although it would not execute the macro. I have had other Excel issues as it relates to UiPath. Files from SAP saving unconverted even when spreadsheet is clearly defined - saving as .txt when the activity is selecting .xlsm. I am trying to work through these issues with our IT staff. Thanks for your help!


#9

Hi i have a similar question iam.trying to pass a column value in excel name for example …filename%userid%.csv…How to do this…