Split it into 2 macros and use the Application.OnTime function:
Macro1
Sub Test()
ChDir "C:\Statistiques\Traitement\Excel"
Workbooks.Open Filename:="C:\Statistiques\Traitement\Excel\stats mails.xlsx"
ActiveWorkbook.RefreshAll
With ActiveWorkbook.PublishObjects("stats mails_610")
.HtmlType = xlHtmlStatic
.Publish (False)
.AutoRepublish = False
End With
Application.OnTime Now + TimeValue("00:00:05"), "saveDoc"
' Run save macro after 5 seconds
End Sub
Macro 2
Sub saveDoc()
ChDir "C:\Statistiques\Statistiques"
ActiveWorkbook.Save
ActiveWindow.Close
ActiveWorkbook.Save
End Sub
Havent tested it, but hope it helps,
mccreaso
Bookmarks