change "Microsoft Excel 97-2003 Worksheet (.xls)" to normal excel format in BP?

#1
hi. i have a process that extracts an excel document from sap and saves it. but it extracts it in a weird format, called "Microsoft Excel 97-2003 Worksheet (.xls)". i want to change this without having to open the file (if possible) because the file also has a pop up that says "The file format and extension of 'xxxxxxx.xls' dont match. the file could be corrupted or unsafe. unless you trust its source, dont open it. do you want to open it anyway?"

is it any way of changing the type of file in BP?
 
#2
Hi Hicke,

In this scenario, we need to achieve two goals.

1. To open Excel file without pop up.
2. Convert the file to .xlsx format.

1. To open Excel without pop up: Tweak the Open Workbook code and use the below one. This will turn off any alerts while opening the excel file.

Dim excel As Object = GetInstance(handle)
excel.AskToUpdateLinks = False
excel.DisplayAlerts = False
Dim wb as Object = excel.Workbooks.Open(filename)
name = wb.Name
wb.Activate()
excel.DisplayAlerts = True
excel.AskToUpdateLinks = True

2. To convert the file to .xlsx format: Change the code of default Excel VBO Save Workbook as given below.


Dim wb as Object = GetWorkbook(handle,workbookname)
Dim excel as Object = wb.Application

excel.DisplayAlerts = False
wb.SaveAs(filename,FileFormat:=51)
excel.DisplayAlerts = True

newworkbookname = wb.Name

Please note to provide filename with an extension, for example, "Excel.xlsx" as Input Parameter. You can change the FileFormat enumeration in the code depending upon the file format you need.

Use https://docs.microsoft.com/en-us/office/vba/api/excel.xlfileformat to check Excel FileFormat enumeration.


Thanks and Regards,
Jothin
 

Attachments

#3
Для того, чтобы самостоятельно открыть «Личный кабинет» на официальном сайте ПФР, сперва нужно зарегистрироваться на портале государственных услуг www.gosuslugi.ru https://cabinet-pfrf.ru/ ПФР предлагает клиентам возможности узнавать пенсионные накопления и пользоваться некоторыми сервисами в режиме онлайн. Каждому желающему доступен вход в личный кабинет пенсионного фонда по СНИЛС.
 
Top