Creating Word document from Excel Add-In with Office.js - excel

Is it possible to create a .docx file from an Excel Add-In written in office.js?
My use case would be to open an Excel file (on Windows, so the host is an Excel Application), open the Add-In and the Add-In creates a Word document based on data within the Excel file.
From the things that I've seen, it is not possible to call the Word.run() host function from inside a Excel Add-In. I will always get an error that the namespace Word is unknown.
Is this even an intended feature to make 'cross-host calls'?

I had almost the same question: How to get the active PowerPoint presentation from Excel in office.js? and got the answer:
An Office add-in can only work with the Office application (Excel,
Word, PowerPoint, etc.) in which it is open. It cannot reach outside
the Office application to work with a document in another Office
application.
Eventually I moved back to VSTO and C#

Related

How to know that a VSTO Word and Excel addin is being started by the Windows Explorer preview pane?

I have noticed that when users have the Windows file explorer preview pane enabled and then view a Word or Excel file, that my VSTO addin is started. Further my addin starts again when the user double clicks on a excel or word file.
What properties in Word and Excel do I need to check at startup to know that it is the preview pane?
For people's reference I did find a discussion on this for Powerpoint in this SO question.
When Word and excel are started by the file explorer as a preview then what I have found is that you can check for a commandlinearg of -Embedding
Environment.GetCommandLineArgs().Contains("-Embedding"))
Detecting Automation of Excel is where I found this answer. This question is about automation.
Also when a user embeds for example Excel in Word and then edits the embedded Excel the VSTO addin will start multiple times. You can check for the -Embedding arg for this as well.
Typically the ribbon bar is not visible when Office applications are used for rendering documents in the Windows explorer. You may use the following code to check that:
Application.CommandBars("Ribbon").Visible

Excel 2013 - "At startup, open all files in": only works first time

Afternoon all,
I've just upgraded to Office 2013 and I'm trying to get to grips with it.
Since Excel 2003, through 2007 and 2010 I have created and used standard templates for new workbooks and sheets which I store in a specific location. I use the "At startup, open all files in" option in the Advanced Excel options to reference this location so each time a new workbook or sheet is opened, it uses my templates.
In Excel 2013 it works in the first workbook but any workbook after that I open just opens as standard. If I create a new instance of Excel by holding down Alt when I click on it, it also works correctly. It seems as if the change in Excel 2013 to open up workbooks in the same instance which behave as separate instances has the downside of the startup files not being accessed.
Does anyone know how to correct or get around this?
Edit: Same problem if I use the default XLStartup folder
SliderSteve

How to recognize that Excel is really closing in an XLL add-in?

According to MSDN, Excel will call xlAutoClose on an xll add-in, when the add-in is unloaded (be it because excel is closing or maybe the add-in is being removed manually).
Unfortunately xlAutoClose is also called when the user tries to close the spreadsheet, but then cancels when prompted to save their work.
According to the Excel Add-In dev documentation ("Financial Applications using Excel Add-in Development in C / C++"), when Excel is really closing, xlAutoClose will be followed by a call to xlAddInManagerInfo. Unfortunately I found it to be not true (tested both on 2007 and 2010 versions of Excel).
Is there any reliable way for an XLL add-in to distinguish between attempted spreadsheet close and actual spreadsheet close?
Thanks,
Luke

Excel 2007 does not allow reference to xlam from xlsm

I am running Excel 2007 under Windows 7 Pro.
I have two add-ins which I have saved as .xla, i.e. as "Excel 97-2003 Add-in".
One is a "Master" add-in, which refers to the other, the "Slave" (through Tools > References)
In VBA, I am able to make a reference the Master add-in from another spreadsheet saved as .xlsm format. It appears to work fine.
Problem:
I change the format of the add-ins from .xla to .xlam (this is non-trivial, involving saving as .xlsm format in between)
I change the reference in the Master .xlam to point to the new Slave .xlam. That works fine, and can be tested.
But when I try to reference the master from the .xlsm spreadsheet, then I get the message "Can't add a reference to the specified file".
If I try again I get a message that just says "400".
Can anyone suggest why it is not possible to add a reference to .xlam from the .xlsm? The code is identical across the two add-in formats. There is no problem in referencing from the Master .xlam to the Slave .xlam . The problem only appears when trying to reference the Master .xlam from the .xlsm spreadsheet.
Both add-ins also refer to other libraries:
Visual Basic for Applications
Microsoft Excel 12.0 Object Library
Microsoft Office 12.0 Object Library
Microsoft Scripting Runtime
Microsoft Forms 2.0 Object Library
I also tried saving the Master as .xslm, and referencing that. It works fine but of course the worksheets of the Master add-in are then visible, which I wanted to avoid.
Thanks for your help.

how to use a macro in excel

The question is there are 'n' different ppts and I want to put all the ppts in one single ppt. Condition is I should not use copy paste rather I should write a function in excel using macros to get it done. So how do I do this?
It looks like you need to automate PowerPoint from Excel. The How to automate PowerPoint by using Visual Basic in Office 2003, in Office XP Developer, and in Office 2000 Developer article describes all the required steps for getting the job done. Be aware, the reference number corresponds to the Office installed on your machine. For example:
Microsoft PowerPoint 15.0 Object Library
Stands for PowerPoint 2013 and etc.

Resources