Retrieving the another file name of excel files and then trying to use that name in docx file

Hello guys

I am trying to retrieve the name from the an excel file then using this name from the excel file to name a “.docx” file.

But it is showing “file name format wrong”.

I am using the Directory.GetFiles(“folderPath”)

then using For each activity to get the file name then using this file name in the copy file activity to get the final name.

Please guide me.

Thanks in advance.

1 Like

Can you post the error screenshot and the workflow how you are trying to do that @AryanSingh?

Hi

@AryanSingh

How are you retrieving the File Name ?

can you use the below expression to fetch the filename and use it in an assign activity with an extension changed.

Assign:
string DocFilename= Path.GetFilenamewithoutExtension(ExcelFileName)

assign DocFilename =StoragePath+“"+DocFileName+”.docx"

storagePath is the folder path where the doc file has to be stored.

Regards
Vishnuvarthan P

@HareeshMR
@vishnuvarthanp

Please check the image:

You are trying to open a word document using excel application scope @AryanSingh

Hi

Please use the below expression : U r retrieving the fileName along with extension which is causing the issue

1 Like

yes

@HareeshMR

1 Like

@vishnuvarthanp

Let me try. I will try.

1 Like

Yeah, I mean, reading the docx file using excel application gives the error. Excel Application scope is specially mentioned to open the excel files.

So, use word document activities or open application to open the word document @AryanSingh

1 Like

Hi

What @HareeshMR Said is correct.

Please also install Uipath.WordActivities from Manage packages to read doc file.

regards
Vishnu

@HareeshMR

what i am trying to do is. For each excel file in the a folder i am trying to get the name of the those excel files.

since i am copying the doc file then making the changes and using the name retrieved for the current excel in for each activity then showing this error

here are the few steps :

  1. Get all the files into a directory using Directory.Getfiles(“Path”)
  2. Use For each loop to loop through all the items and it will give you the full path of the each excel
  3. Then use the string manipulations to get the values as (item.split("\“c)).split(”."c).First()
  4. This will give you the file name. So you can use it
2 Likes

ok thanx.

@HareeshMR

1 Like

@vishnuvarthanp
@HareeshMR

Thanx brothers. Issue solved.

1 Like

@vishnuvarthanp
@HareeshMR

Can u guys tell me in if activity, when i want to use Not equals to sign. It should be <> (This sign), right?

or any other symbol?

1 Like

Yes it is

1 Like

@HareeshMR

Thanx buddy

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.