This worked fine for me, in Office 2013 SP1 32 bit. #include <Excel.au3> Local $sModule = @TempDir & "\Module.bas" Local $sMacro $sMacro &= 'Attribute VB_Name = "Module1"' & @CRLF $sMacro &= 'Sub MergeWkbks()' & @CRLF $sMacro &= 'Path = "' & @DesktopDir & '\MergingExcelTest\"' & @CRLF $sMacro &= 'Filename = Dir(Path & "*.xlsx")' & @CRLF $sMacro &= ' Do While Filename <> ""' &