UiPath操作Office软件的方式,这里说一下用PowerShell调用Office的COM组件的方式
老生常谈~每个程序员都要至少掌握一门脚本编程语言。。。
EXCEL:

1 $excel = New-Object -ComObject Excel.Application; 2 $excel.DisplayAlerts = $False; 3 $wb=$excel.Workbooks.Open("oldexcelpath"); 4 $wb.SaveAs("newexcelpath",51,"password"); 5 $wb.Close(); 6 $excel.Quit();
在ISE上运行正常,但移植到UiPath中就报错了 类似Old Format or Invalid Type Library
将地域重新设置下就可以了。

1 $currentThread = [System.Threading.Thread]::CurrentThread; 2 $culture = [System.Globalization.CultureInfo]::GetCultureInfo("en-us"); 3 $currentThread.CurrentCulture = $culture; 4 $currentThread.CurrentUICulture = $culture;
WORD:

1 $Word=NEW-Object –ComObject Word.Application; 2 $Document=$Word.documents.open("oldpath"); 3 $Document.SaveAs([ref]"newpath",[ref]12,[ref][Type].Missing,[ref]"password"); 4 $Document.Close(); 5 $Word.Quit();
详细参数列表,请参见MSDN