简体   繁体   中英

Run Worksheet_Open code with a userform active

My program calls 7 subroutines in the workbook_open event. I want to show a progress bar (with a 'Done' button when the progress is 100%) but when I show the progress bar, it doesn't run the workbook_open event anymore until I close the userform, then it goes on running. Is there a way to show a userform with the code running in the background?

Private Sub Workbook_Open()
    frmProgress.Show

    'Here it stops running the code

    frmProgress.lblTask = "Updating pivottables..."
    Call updatePivots
    ufProgress.Label1.BackColor = &H8000000D
    frmProgress.lblTask = "Updating data..."
    Call updateData
    ufProgress.Label2.BackColor = &H8000000D

    'Some More code

    frmProgress.lblTask = "Done!"
End Sub

I know the changing of the colors and the multiple labels are not efficient, I'm working on that.

您应该将代码放在UseForm Activate事件处理程序中,该事件处理程序将在Workbook Open事件处理程序上触发:)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM