Excel application scope path problem

when writing file path in excel application scope activity it show this error-----

Excel Application Scope: Failed opening the Excel file C:\Users\Admin\Desktop\EmergeFlow\Test Folder\Spain\Caisse de Dépôt et Placement de Québec\2019\Regime de retraite des employes du gouvernement et des organismes publics (RREGOP)\Allocation FIles\WHT-301-361-362-Spain-2019.xlsx.

Possible reasons: the file is corrupt, the file is already used by another process or you don’t have permissions to open the file.

File path was too long is it because of this?

@Anil_G @sangeethaneelavannan1 do you have any idea?

Hi @pravin_bindage

It’s possible that the error is caused by the file path being too long. The maximum length for a file path in Windows is 260 characters, and if the file path for the Excel file you’re trying to open exceeds this limit, you may encounter this error.

Another possible reason for this error is that the file is corrupted or being used by another process, but the file path being too long is the most likely cause. You can try moving the file to a different location with a shorter file path to see if that fixes the issue.

that excel file name is too long and there is no possibility to reduce it.any other way to resolve this issue

Hi @pravin_bindage
Try the below vb.net code to read excel data

VB Code:

Dim excelApp As Excel.Application
Dim excelWorkbook As Excel.Workbook

excelApp = CreateObject(“Excel.Application”)

excelWorkbook = excelApp.Workbooks.Open(“C:\Path\To\Excel\File.xlsx”)

Dim dataTable As DataTable

dataTable = New DataTable()

Dim rows As Excel.Range
Dim columns As Excel.Range

rows = excelWorkbook.Sheets(“Sheet1”).UsedRange.Rows
columns = excelWorkbook.Sheets(“Sheet1”).UsedRange.Columns

For i As Integer = 1 To columns.Count
dataTable.Columns.Add()
Next

For i As Integer = 1 To rows.Count
Dim row As DataRow
row = dataTable.NewRow()

For j As Integer = 1 To columns.Count
row(j - 1) = excelWorkbook.Sheets(“Sheet1”).Cells(i, j).Value
Next

dataTable.Rows.Add(row)
Next

excelWorkbook.Close()
excelApp.Quit()

Return dataTable

what was the limit for no. of character in excel app scope file path field?
My file path length is 227 char
is it permissible or not?
@Kaviyarasu_N

Hi @pravin_bindage

  1. Have you tried with Workbook activity Read Range activity?

Or

  1. Use Kill Process activity ->> Set the Process Name → Excel before the Read range or excel Application scope

Or

3)Can you create the variable and pass the path in the Assign activity and Pass that variable in the Read range activity

Regards
Gokul

@pravin_bindage

Does file contain any hyper links or may be file is corrupted …To check can you copy the file data to another file and try accessing it

cheers

no it does not contain hyperlink & file was also ok.
the problem is with only character in path
it was working upto 218 characters in file path string
if length of characters exceeds then this error occurs

@pravin_bindage

As you said its the official limit.Can’t help

Error message when you open or save a file in Microsoft Excel: "Filename is not valid" - Microsoft Support.

cheers

1 Like

Can you able to Rename the file and check it using Rename File activity

Have you tried with this?

Regards
Gokul

yes i used variable also but its not working

Have you tried with this? @pravin_bindage