Sub Document_DocumentSaved(ByVal doc As IVDocument) Static DocumentSavedLock As Boolean 'defaults to true ' This avoids infinite recursion by triggering a DocumentSaved event ' when we save the document. If DocumentSavedLock = False Then DocumentSavedLock = True UserForm1.Hide Exit Sub End If DocumentSavedLock = False UserForm1.Show (False) UserForm1.ProgressBar1.Value = 0 UserForm1.ProgressBar1.Min = 0 UserForm1.ProgressBar1.Max = Pages.Count + 1 UserForm1.Repaint ' We treat saving the document itself as one tick on the progress bar. Application.ActiveDocument.Save UserForm1.ProgressBar1.Value = 1 UserForm1.Repaint For Each Page In Pages Page.Export doc.Path & "\" & Page.Name & ".png" UserForm1.ProgressBar1.Value = (Page.Index + 1) UserForm1.Repaint Next Page End Sub