cancel
Showing results for 
Search instead for 
Did you mean: 

Saving MHTML file as XLSX file

ChrisRhea
Level 2
Hello,

I'm downloading a file from SAP as an MHTML file in Excel. Once it opens, I need to save as an XLSX file type. How can I accomplish this in BP without losing the formatting of the opened file? I tried using the Excel VBO Save Workbook As, copying from source to another destination workbook, etc... Nothing is working. Would appreciate any guidance!


------------------------------
Chris Rhea
------------------------------
1 REPLY 1

AndreyKudinov
Level 10
Excel VBO Save Workbook As is not what it says - just new filename. To change file type you need custom action that lets you set file type, which should be available in extended VBO I guess. 

Either way, code would be something like this, with new input number fileformat (values here: https://docs.microsoft.com/en-us/office/vba/api/excel.xlfileformat, you want 51):
newworkbookname = ExecWithTimeout(Timeout, "Save Workbook As",
Function()
    Dim wb as Object  = GetWorkbook(handle,workbookname)
    Dim excel as Object = wb.Application

    excel.DisplayAlerts = False
    wb.SaveAs(filename, fileformat, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, True)
    excel.DisplayAlerts = True
    Return wb.Name
End Function)​


p.s. That "True" in the end is irrelevant for you, but it tells excel that csv(fileformat=6) for example to be saved using local language settings.



------------------------------
Andrey Kudinov
Project Manager
MobileTelesystems PJSC
Europe/Moscow
------------------------------