<html>
    <head>
      <base href="https://bugs.documentfoundation.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_UNCONFIRMED "
   title="UNCONFIRMED - VBA Macro: Application.ActiveWorkbook.SaveAs saves invalid files"
   href="https://bugs.documentfoundation.org/show_bug.cgi?id=118146">118146</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>VBA Macro: Application.ActiveWorkbook.SaveAs saves invalid files
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>LibreOffice
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>6.2.0.0.alpha0+ Master
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>UNCONFIRMED
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>medium
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>BASIC
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>libreoffice-bugs@lists.freedesktop.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>kelemeng@ubuntu.com
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="http://bugs.documentfoundation.org/attachment.cgi?id=142708" name="attach_142708" title="Example file from Excel">attachment 142708</a> <a href="http://bugs.documentfoundation.org/attachment.cgi?id=142708&action=edit" title="Example file from Excel">[details]</a></span>
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@42, Branch:master, Time: 2018-05-27_05:50:28
Locale: hu-HU (hu_HU); Calc: group threaded</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are the assignee for the bug.</li>
      </ul>
    </body>
</html>