Reactivating COM AddIn with Word Interop - ms-word

I've written a custom ribbon for word. In my winForms-application I also open a word document with word-Interop to create some texts with word.
When I use normal word documents my ribbon is shown correct but when I open the document in my application then the ribbon is gone.
I found out that it is somehow disabled in the COM-AddIn-Options in Word. When I reactivate it manually it appears.
How can I reactivate it programmatically?
[Update]
For better understanding: I have two solutions.
1) A AddIn for Word which displays a ribbon
2) A winform-application which has a winword-control which loads word in it.
When the second one is started the first one is not available anymore.

To answer your question, it's not possible to programatically re-enable your add-in from the add-in itself. Think about it - it doesn't get loaded, so its code won't get run. So nothing you put in your code will re-enable the addin, because it won't get executed.
The only way would be to create a watchdog process that checks if the COM add-in has been disabled every 10 minutes or so, and re-enables it. You'll need to know where Word stores those settings though.

Related

Dynamic data manipulation in word online

I am trying to build a task-pane add-in for word online which can do mail merge like desktop office. Now I understand that word online does not support mail merge out of the box, so I thought about the following steps -
Create a template (DOTX) using desktop office which will contain Region or something like a merge field etc. Upload the template to one drive.
Open a blank doc and add a task pane add-in in word online. This is temporary step for now.
Click a button on the add-in.
This click will stream the template (DOTX) from server using an app service call.
Render the stream into word online web page.
Edit and save.
Close word online and reopen.
Click the doc link.
This will render the doc in word online.
Add the add-in in the task pane (temp step).
Click edit button.
Call app service to fetch the latest merge data source.
Traverse through the word xml and replace the values corresponding to the region or special keys.
Re-render the doc.
My users will have E1 subscription of office 365.
Is this thought process logical and achievable with word online? Thanks in advance!...
I think your approach is much more complicated than it needs to be. Word Online supports Add-ins created using the JavaScript APIs, as supported by the information in this article: https://msdn.microsoft.com/EN-US/library/office/dn833104.aspx
It should be possible for you to create the "template" on the Desktop (Word 2013 or 2016 is required - but only 2016 supports the current full scope of the JS API) and "insert" your add-in, which links it to the document. Opening the document in Word online should automatically load the add-in, that can then link to the data source and fill in the data.
As data targets ("merge fields"), I recommend you use Content Controls.

Automatically loading Word Task Pane Office Add-in

We are developing a Word Task Pane Office Add-in (not VSTO) for internal organization documents
In Word 2013 (desktop) when we insert the add-in and save the document, when we reopen that document the add-in is automatically loaded.
In Word Online, this behavior is different, the add-in doesn't get automatically loaded. The user has to manually insert the add-in every time the document is opened.
Is there a way to automatically load it in Word Online?
Would running our own Office Web App Server help?
Is there a way to load the add-in through a parameter? (maybe query string?)
Thanks
We have changed the behaviour you describe: starting in January, Word Online add-ins will be persisted in the document just like they are in Word for desktop. So #1 is not supported now but will be soon. Workarounds like #2 and #3 are not available now.
Thanks!
-Michael (Microsoft Program Manager for add-ins)
Thank you for posting this issue and giving us the opportunity to find a resolution. It looks like we are having a temporary issue at present where the Office Add-ins width is getting saved to 3 pixels. We are striving to find a resolution as soon as possible. In the mean time you can try the following workaround
Temporary workarounds:
1.Opening the file in excel client app and saving the file will fix the width issue because we have a minimum width set in excel client app.
2.open the file in open xml editor, locate \xl\webextensions\taskpanes.xml and edit 'width' property of entry to a greater value, say, 300.
After the file is edited in client or excel client, excel client respects the new value and it do NOT go back to value 3. The issue seems to be only repro with the add-ins inserted in excel WAC only.
We will update the article once it is fixed
Thanks,
Sky
Microsoft Program Manager.

MS word template wont save add-in as active

I have one file with macros (file type is word macro-enabled template .dotm), same file also has a ribbon modification (a button in custom tab, which calls macros in same file).
Macros are very simple - just insert static text in current document.
I have a different file (same type .dotm) where I include first file through "Developer->Add-Ins". As a result I have a new ribbon tab with a button. If I press the button I have text in document - everything works. Until I save/load file. It never saves included add-in state, this add-in is always inactive (if I activate it manually it works).
If I put the template file into the Word startup folder it loads but I do not want to load it for all documents, just for that one.
I tried enable all macros, sign first file - nothing works. That add-in is unchecked (you can see it in list, but it is marked as inactive).
(Show add-in user interface errors - does not show anything).
Why won't Word save included add-in as active and how to make it to save add-in as active?
Looks like you can not load template/add-in for only single document.
You can load add-in for session or put it to startup folder to load it for each document.

Network Diagram, Word etc

Making a word document of our network set-up.
We have about 7 servers and I need to include screenshots and other info on each.
Is it possible to have a pic of the server that when clicked will open up another word doc that reveals all of the other info. Can this then be mailed to someone easily?
I think that you should have actually tried to do it in Word before asking. The answer is trivial. For completeness sake:
Right-click on the image, choose "Hyperlink..." from the menu. Select the document you want from the resulting standard file selection dialog.
That's it. Doing ctrl-click on the pickture will open up the document selected though you will probably get a security warning first.
You can also do it from a VBA macro. First select the desired image and then:
ActiveDocument.Hyperlinks.Add Anchor:=Selection.Range, Address:= _
"C:\Users\me\Documents\a-document.doc", SubAddress:=""
So you could automate the process of server discovery (or maybe you have the data in a spreadsheet that you could use), adding images and hyperlinks automatically. Probably not worth it for just 7 servers.
I'm not clear what you mean by the last part about emailing. Do you want to email the Master word document or the one opened after clicking on the hyperlink? Either way, Word has a menu option for doing this.
If you are wanting to send the document that is opened from the hyperlink - do you actually need the user to open that document or would you rather email it directly? A simple macro can be written that will ask you for the target email address and send the document directly without having to open it. There are really too many possibilities to write down here - we need more information.

AutoNumbering in Visio and PPT

Is there a way to autonumber when you open up visio or ppt? I need a number to count on the slide in ppt and in a shape in visio. I have tried insert excel that has a macro that will do what I want it to do but I can't get it to work when you open up visio/ppt. All I want is a number count to display when I open up the document.
You can do this in PowerPoint:
Insert > Header/Footer...
Check the Slide Numbers box.
PowerPoint doesn't have any mechanism for running code automatically in response to a user opening a document file. You pretty much need to write an add-in that traps and responds to events like users opening a file, and the add-in must be installed on each user's PC where you expect this to work.
For Visio, this this MSDN Article:
Visio: How to Use Background Pages to Set Up Automatic Page Numbering may be of assistance.