UserForm as loading bar flickering

Started by lecrick, April 19, 2018, 02:46:53 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

lecrick

Hello guys!!

I'm using a UserForm to make a loading bar to notify the user on the remainig time for the macro to end but even with "ScreenUpdate = False", my UserForm still flickering.
When the code is running, both my Excel and Visio are hidden. Only the UserForm is shown and at every step my loading bar is incremented, the UserForm's window become active which makes the PC unusable.

Does someone has a solution?


Here's an exemple of my code :


Sub main()

Application.ScreenUpdating = False

'code (loop)
progression = progression + 1
ProgressBar.barre.Width = progression
ProgressBar.Show 0
next

'code (loop)
progression = progression + 1
ProgressBar.barre.Width = progression
ProgressBar.Show 0
next

AppVisio.ActiveDocument.SaveAs

progression = 150
ProgressBar.barre.Width = progression
ProgressBar.Show 0
Unload ProgressBar

Application.ScreenUpdating = True
AppVIsio.Quit
End Sub



Sub barre_progression()
    ProgressBar.barre.Width = progression
    DoEvents
    ProgressBar.Hide
End Sub



Private Sub Workbook_BeforeClose()
Application.Visible = False

main

ThisWorkbook.Saved = True
Application.Quit


Thanks!