Convert .xls to .xlsm

Hello everybody,

I have problem for convert .xls to .xlsm.
I use activities “move file” for rename extension but my outputfile have a problem of format, cant’ open …

Have you ever had this problem ?

Hi

Welcome to UiPath forum

Have a view on this custom component

Cheers @mateo.drouillard

Hi @mateo.drouillard ,

We cannot create .xlsm by moving the file with the different extension. we can use invoke code activity and insert the below vb code to convert xls file to xlsm file with macro enabled. please refer the below code. and also please make sure that you have imported the following name space microsoft.office.interop.excel. thanks.

Dim excel As Microsoft.Office.Interop.Excel.Application
Dim wb1 As Microsoft.Office.Interop.Excel.Workbook
Dim ws1 As Microsoft.Office.Interop.Excel.Worksheet
excel = New Microsoft.Office.Interop.Excel.ApplicationClass
wb1 = excel.Workbooks.Open(“C:\Test.xlsx”)
wb1.SaveAs(“C:\Test.xlsm”,Microsoft.Office.Interop.Excel.XlFileFormat.xlOpenXMLWorkbookMacroEnabled)
wb1.Save
wb1.Close
excel.Quit
ws1 = Nothing
wb1 = Nothing
excel = Nothing
GC.Collect

2 Likes

Thanks @kirankumar.mahanthi1 and @Palaniyappan for yours answers. But the two solutions dosn’t work …

I have idea :

  • copy the sheets(1) of my workbook
  • create other workbookk
  • paste the sheets(1)

it’s possible ?

@mateo.drouillard

You can use Excel Application scope Read Range activity which sheet you need to write to another sheet

Now use Write Range activity and give the file name as path.xlsm

If the xlsm file is available in the path then it will write into that file, else it will create a new file

Hope this may help you

Thanks

Thanks i think its the best solution.

Do you a file.xaml for the example ?

Thanks

@mateo.drouillard

Can you try and let us know if you struck anywhere

Currently I don’t have the xaml file

Thanks

Thank your very much.

See you later on the forum !

Bye

1 Like

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