user2300652
user2300652

Reputation:

VSTO splash screen or progress bar

I have a project that I'm doing with

Microsoft VSTO (office 2013 excel) 

I have certain things that make calls that take maybe 10 seconds to come back.

Ideally I would like to display an progress bar or some status... After a lot of searching I found an article that is titled:

How do I create a splash screen window for the VSTO applications? http://www.datazx.cn/Fv7p5a/xw/oa2v/2q7xs6/mcccjfti-988m-f8r8-8d44-bstb4rfsi4xm23rsdfd.html

So I started creating this code in a form, but then I realize that I need to call it up within my methods and really attach events etc...

The article says to

"display a modal form on a background thread"   What is the best way to do this?

Upvotes: 4

Views: 3297

Answers (2)

Dorian Oria
Dorian Oria

Reputation: 139

Following you will see a way I programmed a Splash Screen for Excel-VSTO in C#. My Excel file is enabled for macros (.xlsm). These are the steps:

  1. Create your splash screen. Let's assume the name of the form is SplashScreen.
  2. Go to the code of the object ThisWorkbook.cs
  3. Check the code looks like:
public partial class ThisWorkbook
{
    SplashScreen SC = new SplashScreen();
    private async void ThisWorkbook_Startup(object sender, System.EventArgs e)
    {
        SC.Show();
        await Task.Delay(3500);
        SC.Close(); 
        more code...
    }
}

It is important that you notice that I added the word async to the subroutine.

private void ThisWorkbook_Startup(object sender, System.EventArgs e)

I hope this is very useful.

Upvotes: 1

Brijesh Mishra
Brijesh Mishra

Reputation: 2748

I find it easier to use modal less form on main thread and so far haven't seen any problem with modal less approach. Something like code below

var splashWindow = new SplashWindow();
splashWindow.Show();
splashWindow.SetMessage("Starting please wait...");
DoSomeWork(splashWindow);
splashWindow.Close();

Upvotes: 2

Related Questions