Microsoft Project Application.ProjectAfterClose Event - ms-office

I'm writing add-ins for Microsoft Project. Some of my toolbar buttons are only valid when a Project file is open, and I want to enable/disable them dynamically. Typically I'd watch for files to be opened or closed, then check the count of the open files. However, MS Project's API only has an Application.ProjectBeforeClose Event, and not a ProjectAfterClose event. The ProjectBeforeClose event fires before the user is prompted to save any changes, at which point they can cancel the close, and no additional event fires.
There's also WindowActivate and WindowDeactivate events, but the Deactivate only fires when switching to a different window, not on close.
Has anyone found an elegant solution to simulate the ProjectAfterClose event? Or more specifically, to enable/disable functionality based on whether or not a project file is open?
Thanks,
Thomas

I had the same problem. A not-so-wonderful approach is to use a timer that checks to see if any projects are open...

Related

Startup behavior doesn't work in Excel Desktop

I have an OfficeJS Excel Addin which is used in Online Excel and Desktop Excel. I use feature
Office.addin.setStartupBehavior(Office.StartupBehavior.load);
And it work fine for Online Excel: every time I start the excel - the plugin loads in background and ready to use.
However, in Excel Desktop it doesn't work. If I "alert" current behavior (after click on command to run the addin), it says "Load", but anyway it expects user interaction before to start loading the addin.
Any thoughts on this?
Prerequisites: SharedRuntime, Windows 10, Angular based addin
link to doc: https://learn.microsoft.com/en-us/office/dev/add-ins/develop/run-code-on-document-open
You can configure your Office Add-in to load and run code as soon as the document is opened. This is useful if you need to register event handlers, pre-load data for the task pane, synchronize UI, or perform other tasks before the add-in is visible. When your add-in is configured to load on document open, it will run immediately. The Office.initialize event handler will be called. Place your startup code in the Office.initialize or Office.onReady event handler. Read more about that in the Run code in your Office Add-in when the document opens article.

How do I use the setStartupBehavior API call?

I am trying to register event handlers when a document first opens up in Excel as it shows in the documentation. However, it tells me that I need to configure my code to include this: Office.addin.setStartupBehavior(Office.StartupBehavior.load); I'm not too sure where I am supposed to use this. I created my project using the yeoman generator for Office.
It depends on whether you want the users to decide whether the add-in runs when the file opens or whether you want to ensure that it does. If you want the user to decide, include this line of code in an event handler for a button or other UI. There's a sample add-in that does this at: Excel shared runtime scenarios.
If you want to ensure that the add-in runs whenever the file opens, then include the line of code in the Office.initialize method or Office.onReady method. The first time the file opens, the add-in will not run immediately and the user will have to manually invoke it. But, after that, the add-in will run whenever that file is opened.

Office Add-ins: Any way to have one always running?

I have an idea for an Office/PowerPoint Add-in. Most of the ones I've seen (and what is sampled in the documentation) are add-in actions that are triggered by a button click in the ribbon, or triggered by an action the sidebar. However, I need the Add-in to be running from the moment PowerPoint opens.
Is there a way to have a add-in that is running in the background? Listening for events? My idea involves catching when the slide changes - but I need this to happen when the PowerPoint is in Presenter view.
Is this currently possible?

How to write custom code on save of Share Point List New Item

I want to write custom code on Click of Save, when a new List Item is created in Share Point site.
Which is the easiest and most well controlled way to do that.
I have C# Code to do the stuff
If you want to trigger custom logic after item saved, there are two solutions.
SharePoint add-in Remote event receiver
SharePoint 2013 workflow
If you want to trigger event before item saved, check PresaAction(JavaScript)
As #Lee stated (link) there are a few options.
If you want to run server side code? The option i would go on is Custom code to run an Eventreceiver (not to be confused with Remote eventreceiver). I would prefer this option than doing it by using a remote Event Receiver.
Then you can trigger this on the ItemUpdated or ItemAdded event.
Microsoft's article regarding How to: Create an Event Receiver

Popup window inside a task pane add-in

I have a task pane add-in in Office.
I have an item in the task pane, and a delete button. Now, when users click on the delete button, I want to pop up a small window to ask if users are sure about the deletion. If yes, we continue; if no, we go back to the current page.
It is like the Window confirm() method for a web page.
Does anyone know how to pop up this small window in the task pane add-in?
Additionally, if I want users to choose an option in this popup window (eg, choosing a colour between blue or red) before continuing (let's forget yes or no), how could we realise this? More generally, is it possible to create a custom confirm box?
As you design and build web apps for Office 365 or add-ins for Office and SharePoint, you can take advantage of the Office UI toolkit to make your experience look and feel like Office. The Office UI toolkit has key plug and play components that will make it easy to create web experiences that connect to and integrate with Office.
One of the controls offered by Office Fabric JS package is Dialog which has a lot of customization. I believe you'll find one suitable for your task.
Yet another option is to use any UI package which has variety of UI controls, for example jQuery mobile. And finally you may just write your own control.

Resources