<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 - FILEOPEN XLSX Basic code with CreateObject("Scripting.FileSystemObject") and “For Each ” loop does not work"
href="https://bugs.documentfoundation.org/show_bug.cgi?id=118241">118241</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>FILEOPEN XLSX Basic code with CreateObject("Scripting.FileSystemObject") and “For Each ” loop does not work
</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=142919" name="attach_142919" title="Example file from Excel">attachment 142919</a> <a href="http://bugs.documentfoundation.org/attachment.cgi?id=142919&action=edit" title="Example file from Excel">[details]</a></span>
Example file from Excel
If we try to run the macro in the attached file, the file listing For Each loop
will not run.
Steps to reproduce:
1. Create a new spreadsheet with Microsoft Excel 2016/2013
2. Open the Visual Basic window
3. Add a new Module to your VBAProject
4. Use this simple code:
Sub fileoperation()
Dim fso As Object
Dim dir As Object
Dim Files As Object
Dim File As Object
Dim i As Integer
Set fso = CreateObject("Scripting.FileSystemObject")
If Range("D2") = "" Then
x = Range("B3").CurrentRegion.Rows.Count + 1
sx = Cells(x, 2).Address(False, False)
Range("A3:" + sx + "").ClearContents
MsgBox "Empty data"
Else
s = Range("B3").CurrentRegion.Rows.Count + 1
st = Cells(s, 2).Address(False, False)
Range("A3:" + st + "").ClearContents
a = Range("D2")
If fso.FolderExists(a) = False Then
MsgBox "Folder doesn't exists"
Else
Set dir = fso.GetFolder(a)
Set Files = dir.Files
i = 2
For Each File In Files //This loop does not work in LibreOffice.
Cells(i + 1, 1).Value = File.Name
Cells(i + 1, 2).Value = File.Path
i = i + 1
Next File
MsgBox "Found " & Files.Count & " files."
End If
End If
End Sub
5. Write a Directory path (which contains files) to the “D2” cell. Run the
macro.
6. Save the file as *.xlsm
7. Open the file with LibreOffice Calc. Run the macro.
Actual results: The macro is executed but the “For Each File In Files” was
ignored. So the files name and paths were not listed.
Expected results:
This simple basic code run perfectly in Microsoft Excel, even if I reopen the
file with Microsoft Excel, after I saved in LibreOffice Calc. This simple macro
should run perfectly in LibreOffice Calc.
Version: 6.2.0.0.alpha0+
Build ID: c3e552ac25be001a623469c549ee8d0719b98133
CPU threads: 1; OS: Windows 6.1; UI render: default;
TinderBox: Win-x86@42, Branch:master, Time: 2018-06-13_23:01:19
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>