VB.net - Form won't show - vb.net

My problem concern an application which is currently running in production since 6 months. But last week, one user reported me this :
Above all, this application is a complement to Outlook, which allows users to create, edit and delete tickets through a new tab in the ribbon.
When this user clicks on a button (Create), a window is supposed to appear. In my code, this window is used in two places, one to create the ticket and the other to edit the ticket. When the user wants to edit a ticket, this window appears without problem. But just to create, he won't appear.
I call the window like this for creating :
Dim oForm1 As Create_form
oForm1 = New Create_form(Nothing)
oForm1.Show()
And like this for editing :
Dim oForm1 As Create_form
oForm1 = New Create_form(ticket)
oForm1.Show()
And here is the constructor :
Public Sub New(ticket As Ticket)
InitializeComponent()
MaximizeBox = False
actualTicket = ticket
Init_List()
Init_Fields()
End Sub
I have looked for solutions on the Internet, but it seems I am the only one with this problem. This code worked for this person until last week without any change.
One possibility I thought about is the Microsoft redistributable and the Outlook version (Developed and tested on Outlook 2016, used on Outlook 2013...).
Any ideas ?
Thanks for your help !
Ps : Please excuse my more than average English

First of all, make sure your add-in is enabled and running in Outlook.
Microsoft Office applications can disable VSTO Add-ins that behave unexpectedly. If an application does not load your VSTO Add-in, the application might have hard disabled or soft disabled your VSTO Add-in.
Hard disabling can occur when a VSTO Add-in causes the application to close unexpectedly. It might also occur on your development computer if you stop the debugger while the Startup event handler in your VSTO Add-in is executing.
Soft disabling can occur when a VSTO Add-in produces an error that does not cause the application to unexpectedly close. For example, an application might soft disable a VSTO Add-in if it throws an unhandled exception while the Startup event handler is executing.
When you re-enable a soft-disabled VSTO Add-in, the application immediately attempts to load the VSTO Add-in. If the problem that initially caused the application to soft disable the VSTO Add-in has not been fixed, the application will soft disable the VSTO Add-in again. Read more about that in the How to: Re-enable a VSTO Add-in that has been disabled article.
Most probably the form is displayed behind the Outlook window. To show a form on top of the Outlook window you need to specify the parent window handle. In .net based applications or add-ins you typically use Windows forms classes to show a window. The Show and ShowDialog methods of the System.Windows.Forms.Form class accept an instance of the IWin32Window interface which stands for the parent window handle. See How to set the Window.Owner to Outlook window for more information.

Finally I found the solution, for the creation of one ticket, I'm using the system date with a specific function. But, the user who have the problem change the default setting in the Windows configuration. So the form could not be displayed due to an unmanaged exception (English date when the software expect French date).

Related

Multiple Outlook Add-ink Panes Displaying at the Same Time

We have developed an Outlook web Add-in but currently when the task pane is open and we open another outlook add-in, our one closes and is replaced with the last selected one. Is there a way to have the task panes stack next to one another so that you can have more than one task pane open at the same time. Appreciate that screen real-estate is an issue but at least 2 would be nice. I thought that I had seen this working somewhere.
Currently there is no way to have two add-ins open side-by-side. We track Outlook add-in feature requests on ourĀ user-voice page. Please add your request there. Feature requests on user-voice are considered, when we go through our planning process.
You can make your add-in pinnable, this way your add-in will not be closed when another add-in is opened.

Which RibbonType will show my custom Ribbon for a sent message in Outlook (2013) VSTO Add-In?

New here so please forgive any faux pas!
I have an Outlook VSTO Add-in with a custom ribbon which I currently display only on composing a new message or replying to a message.
I've selected Microsoft.Outlook.Mail.Compose and Microsoft.Outlook.Mail.Read in RibbonType, and my ribbon appears fine on creating a new message or replying, but not when I go to Sent and open a message.
Can anyone point me in the right direction as to where I can find a list of the RibbonTypes and what they relate to, or offer any advice?
Thanks!
Most probably you get a Fluent UI error.
By default, if a VSTO Add-in attempts to manipulate the Microsoft Office user interface (UI) and fails, no error message is displayed. However, you can configure Microsoft Office applications to display messages for errors that relate to the UI. You can use these messages to help determine why a custom ribbon does not appear, or why a ribbon appears but no controls appear. See How to: Show Add-in user interface errors for more information.
You could use any idMso value which exists on the compose window and doesn't exist on the read inspector.

Word Add-in - find if dialog has focus?

I am writing a word add-in in VB .NET (using Add-in Express, but I don't think that's relevant).
I have created shortcuts, but I only want them to take effect if the document itself is in focus, not a dialog - for example, "Find and replace" or any other.
How do I determine if a dialog has focus?
The "Selection" property of the application points to the selection in the document, even if a dialog is currently selected. I can't find any "HasFocus"-equivalent property anywhere either. I'm running out of ideas :o)
Thanks!
This workaround worked for me:
My add-in keeps a reference to the handle of the most recently activated Word window, by using the GetActiveWindow API during the WindowActivate event of the Word application. This is necessary since, up until Office 2013, the Window object does not expose a handle property.
When a shortcut is triggered, I compare that to the handle of the currently active window, using the same API. If they don't match, I simply don't proceed :o)

How to set Focus and Modal way on a Winform/WPF Application hosted in VSTO Excel 2003 Add-in?

I have 2 questions :
1) In my VSTO Add-in, I created a button. When clicked, it starts a STA thread, launching a WPF Window (which is in fact my real application).
The application is treating Excel Data, sending them to Web services, etc etc.
At a particularly moment, I call :
System.Diagnostics.Process.Start(filePath);
the path is like "C:\file.xls". Indeed, it opens an Excel file.
The problem is that the focus is beeing made on this file instead of remaining the focus on my WPF window.
I tried to set the focus to the Current process, but since the new file opened and my WPF Window are hosted in the same Excel process, it didn't solve the problem at all...
Any idea ?
2) As you can see, as my WPF application is launched in a thread, even using a modal dialog, I can still modify the excel file in background... which is not what I want at all...
How to fix this, blocking the excel file in background ? Is it possible to do this using the Workbook COM object that I can control ?
Ok I solved my problem not using a thread.
I launch my application directly in the VSTA_Main thread (the Add-in thread), causing a freeze on my button...
Since it's not another thread, my entire process in blocking.
For the second question, I launched another Excel process like that :
ProcessStartInfo info = new ProcessStartInfo("Excel.exe",filePath);
Process.Start(info);
I still have a little bug with the generation of the Excel file, but still solved my principal problem.

How to determine if 'SaveChanges:=wdDoNotSaveChanges' was passed to Interop.Word.Document.Close()

I have an issue with an Office addin I'm working on, which is implemented for Office 2003 & 2007. The addin is written in VB.NET 3.5 using VSTO.
The problem comes from some external code which automates a mail merge, opening the mail merge template, merging and then closing the template document. The close is done with this code:
objWord.Documents(sDoco).Close SaveChanges:=wdDoNotSaveChanges, OriginalFormat:=wdPromptUser
Because of some logic in my addin, instigated from the Interop.Word.Application.DocumentBeforeClose event, a message box is opened which prevents the Office document from closing, which breaks the automation.
Is there a way for me to determine the SaveChanges parameter (if any) on a Close within an Office.Interop.Word.Application event, such as DocumentBeforeClose? I'm trying to capture this parameter and determine if it's set to wdDoNotSaveChanges so that I can work around this problem.
I'm pretty sure you get the DocumentSave event BEFORE the DocumentBeforeClose, so set a flag in it, and if that flag is set at close, you know the doc has been saved, but if not, it was not. I've had to do similar things to know whether a Document was SAVED-AS vs just SAVED.
I'm not aware of any way to interrogate the state of that parameter from DocumentBeforeClose.