Opening a new form without clicking anything with Outlook add-in express project

Add-in Express™ Support Service
That's what is more important than anything else

Opening a new form without clicking anything with Outlook add-in express project
 
Fumi




Posts: 12
Joined: 2020-12-12
Currently, when my Outlook add-in express project is loaded with Outlook application, in order to show a new form, I can start a new form up by adding the startup code in click event of a ribbon (see below example). Clicking the button on the ribbon successfully opens a new form. But, what I want to do is to open the form when the Outlook is loaded without clicking anything (I want a new form to be loaded automatically).

Private Sub AdxRibbonButton1_OnClick(sender As Object, control As IRibbonControl, pressed As Boolean) Handles AdxRibbonButton1.OnClick
    Dim fmForm As New fmMain
    fmForm.Show()
End Sub


Google says that I can set up the form to be opened at the start up from here. But, it does not work with Outlook add-in express project. However, if I makes a standard Windows form project, I could change the form.

Project -> Properties -> Startup Form
https://www.youtube.com/watch?v=BvsygXFB07Q

What is the best way for me to open a new form upon the startup of Outlook add-in express project?

Thanks.
Posted 13 Dec, 2020 11:37:24 Top
Andrei Smolin


Add-in Express team


Posts: 18338
Joined: 2006-05-11
Hello Fumi,

Try to use one of the events that indicate that the add-in is loaded or an event that your add-in receives from Outlook. Candidates would be AddinStartupComplete and the first ExplorerActivate event.

Fumi writes:
However, if I makes a standard Windows form project, I could change the form.


The standard project - I assume this is the 'Windows Forms App' project template - creates is a standalone program, an .EXE. An add-in is a .DLL, a specialized variant of the Class Library project. Accordingly, while a program starts by itself (the user starts it), the add-in 'starts' only if its host application loads it. This is the startup-time difference. Other things works or may work differently. I strongly recommend that you download the latest Add-in Express manual version here and check sections:
- Creating Add-in Express projects
- Your first Microsoft Outlook COM add-in
- Best practices and time-saving tips

Also note that a non-modal form usually interferes with the host application's windowing. Typically, affected are tooltips, keyboard shortcuts, focus, etc. If you run into such an issue, you would need to switch to using the form modally or use a pane instead. For this reason, I suggest that whatever controls you show on that form, they control should be placed on a UserControl; this will use the pain of switching to a different option.

Finally, while in a Windows Forms application you work with a single instance of each form (this is typical), you may be required to use many instances of a form in Outlook. Say, consider showing your form from the Click event of a Ribbon button: if you click the button in two or more inspector windows (one by one), you'll get your form creating and showing several instances.

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 14 Dec, 2020 03:43:44 Top