Write Range Illegal characters in path

I’m using this arragement to delete duplicated rows in a .xlsx file
But I keep getting Write Range “Illegal characters in path”
The file contains this data (whole row)

Periodo Mes LINEA Vendedor Zona Doc No_Documento Subtotal Tras de Dtos Vr Descuento Fecha FechaVencimiento Sector Cod_Cliente Nit Cliente Ciudad_Facturacion Ciudad_Destino Grupo Item Descripcion Cantidad Valor_Unitario Peso_Kg Tons Moneda TRM Subtotal_L_Ventas Vr_IVA_Linea Subtotal_L_Costo_Producto Subtotal_L_Margen R_Bruta
2022 7 EMPAQUETADURAS DANIEL FELIPE BEDOYA AGUDELO VALLE DEL CAUCA Factura 20365 2.546.746,84 1.091.462,75 25/07/2022 29/08/2022 MINORISTAS C901556512 901556512-4 EMPAQUES Y ACCESORIOS AC SAS CALI CALI CLUTCH 01P054 CLUTCH VIVA 115-JC110-2HYUSUNG 100 50 2.001,37 0 0 COP 0 100.068,50 13.309,11 38.232,50 61.836,00 61,79

I can’t seem to find any illegal characters ¿any ideas?


Try this

NewDt = Dt.DefaultView.ToTable(True)

This will remove the duplicates in Entire sheet…

If you wants to remove the duplicates in specific column try like this…

NewDt = Dt.DefaultView.ToTable(True,"ColumnName","ColumnName")



For now, can you check content of workbook path property if it contains illegal character?

Or it might be good to check it using GetInvalidPathChars method etc as the following.


filename = "c:\temp\test.xlsx"

Then, the following return True if there is an invalid character.

filepath.Any(Function(c) System.IO.Path.GetInvalidPathChars.Contains(c)).ToString

System.IO.Path.GetFileName(filepath).Any(Function(c) System.IO.Path.GetInvalidFileNameChars.Contains(c)).ToString

Main.xaml (5.7 KB)


Tried but got the can’t convert datatable to string error

Ran it just the same (of course changed the path to the file)
Returned False


If possible, can you share your workflow and workbook file? It’s no problem if dummy.


Hi @Yoichi just found a way easier solution here.

The issue was that the datatable had blank values that the Write Range function was passing as Illegal characters.

Thank you.

1 Like