Reputation: 168
I need a indicator in Excel VSTO to let user know the background task is running, and I'd like to use Excel native progressbar like this:
Does anyone know how to show and hide this in VSTO? Thank you.
Upvotes: 1
Views: 1675
Reputation: 49395
There is no trivial way to customize the status bar with a progress bar...
The Application.StatusBar property allows setting a custom text in the status bar, but not a progress bar. This property returns false
if Microsoft Excel has control of the status bar. To restore the default status bar text, set the property to false
- this works even if the status bar is hidden.
oldStatusBar = Application.DisplayStatusBar
Application.DisplayStatusBar = True
Application.StatusBar = "Please be patient..."
Workbooks.Open filename:="LARGE.XLS"
Application.StatusBar = False
Application.DisplayStatusBar = oldStatusBar
If you want to display a progress bar with some text I'd suggest using task panes for that. Read more about that in the How to: Add a custom task pane to an application article. On the user control you are free to use any .net controls.
Upvotes: 2