Hi all Excel Experts,
I have a vba code to loop folder and print macro. I tried running the code and noticed that for excel files with extention xls & xlsm, it run promptly but for excel files with xlsx, it takes about 5 min to execute the command. Any ideas why? Thank you.
I have a vba code to loop folder and print macro. I tried running the code and noticed that for excel files with extention xls & xlsm, it run promptly but for excel files with xlsx, it takes about 5 min to execute the command. Any ideas why? Thank you.
Code:
Sub PrintTest()
Dim wbSrc As Workbook
Dim wsSrc As Worksheet
Dim MyPath As String
Dim strFilename As String
Application.DisplayAlerts = False
Application.EnableEvents = False
Application.ScreenUpdating = False
MyPath = "D:\xxx\Excel\"
strFilename = Dir(MyPath & "\*.xls")
If Len(strFilename) = 0 Then Exit Sub
Do While strFilename <> ""
Set wbSrc = Workbooks.Open(Filename:=MyPath & "\" & strFilename)
Set wsSrc = wbSrc.Worksheets("xxxxx")
wsSrc.PrintOut
Set wsSrc = wbSrc.Worksheets("yyyyy")
wsSrc.PrintOut
wbSrc.Close savechanges:=False
strFilename = Dir()
Loop
Application.ScreenUpdating = True
Application.DisplayAlerts = True
End Sub