Powerquery 打开扩展名错误的文件

Powerquery opening files with bad extensions

我的一个数据源来自 Excel "xls" 个文件。我把它放在引号中是因为在幕后,创作系统已经生成了一个 html 文件并将其命名为 myFile.xls

手动打开时,Windows给我一个警告,但Excel会打开它。从ExcelVBA,我可以inhibit-warning,而且它悄无声息正确打开。但是试图打开一个充满此类文件的文件夹时,PowerQuery 只是挂起。我一直在手动打开每个 "xls" 文件并另存为 .xlsx。有什么关于摆脱这个手动步骤的建议吗?

[运行 Excel 2013 下 Windows 7.]

添加对 Microsoft 脚本运行时 的引用以便使用 Scripting.FileSystemObject 对象。

Dim app As Excel.Application

'If macro is running within an Excel instance, and you want to use that instance uncomment the next line
'Alternatively, use Application directly
'Set app = Application

'If you want to create a new instance, uncomment the next line
'Set app = New Excel.Application

Dim fso As New Scripting.FileSystemObject

Dim sourceFolder As String
sourceFolder = "C:\path\to\folder\of\pseudo-excel-files"

Dim destFolder As String
destFolder = fso.BuildPath(sourceFolder, "_converted")
If Not fso.FolderExists(destFolder) Then fso.CreateFolder(destFolder)

Dim fle As Scripting.File
For Each fle In fso.GetFolder(sourceFolder).Files
    Dim destPath As String
    destPath = fso.BuildPath(destFolder, fle.Name & ".xlsx")

    Dim book As Workbook
    Set book = app.Workbooks.Open fle.Path
    book.SaveAs destPath, xlWorkbookDefault
    book.Close
Next