[Libreoffice-bugs] [Bug 118146] New: VBA Macro: Application.ActiveWorkbook.SaveAs saves invalid files

bugzilla-daemon at bugs.documentfoundation.org bugzilla-daemon at bugs.documentfoundation.org
Wed Jun 13 15:52:14 UTC 2018


https://bugs.documentfoundation.org/show_bug.cgi?id=118146

            Bug ID: 118146
           Summary: VBA Macro: Application.ActiveWorkbook.SaveAs saves
                    invalid files
           Product: LibreOffice
           Version: 6.2.0.0.alpha0+ Master
          Hardware: All
                OS: All
            Status: UNCONFIRMED
          Severity: normal
          Priority: medium
         Component: BASIC
          Assignee: libreoffice-bugs at lists.freedesktop.org
          Reporter: kelemeng at ubuntu.com

Created attachment 142708
  --> https://bugs.documentfoundation.org/attachment.cgi?id=142708&action=edit
Example file from Excel

There is a VBA macro in the attached file which exports and saves the sheets to
individual/new Workbooks. The main command which will “Save As” the sheets is:
Application.ActiveWorkbook.SaveAs FILENAME, FILEFORMAT ; 
The FILEFORMAT tag was ignored or LibreOffice did not recognize the FILEFORMAT
number (in case of *.xlsx →51). It is a problem when we use a macro in an
*.xlsm/xls file and would like to export the sheets AS *.xlsx. The VBA Project
is not removed properly from the new files and the file extension is wrong
according to Microsoft Excel. (Zip file error). The exported sheets opened
correctly with LibreOffice Calc, but the VBA Project was still there without
any Objects.

Steps to reproduce:
1. Open the attached spreadsheet (“Makro_Save_as_Sheets.xlsm”) with LibreOffice
Calc
2. Run the macro and try to open the exported file with Microsoft Excel.

This is the key command which does the export:
xFile = FolderName & "\" & Application.ActiveWorkbook.Sheets(1).Name & datum &
".xlsx"
Application.ActiveWorkbook.SaveAs xFile, FileFormat:=51

Actual results:
If the source file (which included the macro) was an *.xlsm/xls file
LibreOffice exports the VBA Project even if we set the export format to *.xlsx.
When we try to open with Microsoft Excel, we get an error message. (BAD FORMAT)
The exported sheets opened correctly with LibreOffice Calc, but the VBA Project
was there without any Objects.

Expected results:
We should not get an error message and the “Application.ActiveWorkbook.SaveAs
xFile, FileFormat:=51” command should work correctly even if the source file
was a different type. (BAD FORMAT)

Version: 6.2.0.0.alpha0+
Build ID: 1e9e01dff0a8d65bb10d5a886cca7899b43979da
CPU threads: 4; OS: Windows 6.1; UI render: default; 
TinderBox: Win-x86 at 42, Branch:master, Time: 2018-05-27_05:50:28
Locale: hu-HU (hu_HU); Calc: group threaded

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/libreoffice-bugs/attachments/20180613/a8eba8ba/attachment-0001.html>


More information about the Libreoffice-bugs mailing list