How to prevent Windows Explorer from reusing the existing Excel instances? - excel

I have a number of different programs where I create Excel instances and control them via OLE automation. In some cases the user can also work with these instances through Excel UI (which may involve opening other workbooks), in others they remain hidden.
Problems arise when the user double-clicks an Excel file in Windows Explorer to work with it for some other, unrelated purpose. Explorer would grab any running instance and open the file in it, which may interfere with a running macro, or the instance may be currently hidden and thus unusable via UI.
Is there a way to create an Excel instance in a "special" way to prevent it from being seen by Explorer?

Related

Office js Excel Add-In Sharing state across workbooks

I have recently moved from developing VBA Excel Add-Ins to using the new Office JavaScript Add-ins platform. I am used to my VBA Add-In being active across the whole of Excel and the state of the variables is available no matter what workbook you are interacting with.
This does not seem to be the case with JavaScript Add-ins. I have been testing my Add-In and happened to create a new workbook and noticed that none of the Add-In state appeared to be active any longer.
Am I missing something or is this a consequence of the new Office JavaScript Add-ins architecture where it runs inside a browser within Excel?
Just to confirm I have already enabled the Shared Runtime option, that is not my question. I am able to share state between Commands, Takspane and Functions. But all within a single workbook.
I have tried one of the example Yeoman generator for Office Add-ins and it certainly seems that global variables are not shared between the Add-In in two different workbooks.
This behavior is expected. With Office (web) add-ins, each add-in runs in an embedded JavaScript runtime that is a completely separate process from Office and any other add-ins, so it cannot share data across add-ins. Some people have made sharing across add-ins work using the OfficeRuntime.storage object, but it only works in Windows. It won't work on Mac or in Office on the web. Frankly, the Office platform team considers it a bug that it can be done on Windows and that may be fixed at any time, so you should not create an add-in that depends on it even if you know your add-in will only be run on Windows.
Depending on what your scenario is, you might be able to store state in the document with either Office.document.settings or Office.document.customXmlParts. Another possibility is to store state in a database on your server side.

Excel VBA can’t find project or library once I enable macros

I’ve done a LOT of googling about this and haven’t found anything specific to this situation. Apologies if I missed it.
I have a .xlsm workbook that has a few macros—-one to refresh connections to a Microsoft Access Database, one to refresh pivots, and one to save it to multiple locations.
When I open the file, I get the standard yellow security bar that some active content has been disabled—-but it used to just say ‘macros have been disabled’. When I check the macros, they are there.
BUT when I hit ‘enable’, there’s 2 issues:
it doesn’t enable anything and I have to go to the Trust Center to enable both Macros and External Data Connections. Before yesterday, I never had to do that.
Once I enable macros and external data in the Trust Center, suddenly I get an alert that VBA “can’t find a project or library” and all my macros are now gone.
When I reload the workbook, we’re back to where I started. I have one other workbook with this issue. The other 5 or 6 macro-enabled workbooks do not have this issue.
The issue with these docs persists across 2 other colleagues’ remote laptops. However, when I remote into the office and access the same files in the same folder using VMWare to remote into an office PC environment, they work just fine.
I have tried accessing Tools>References in VBA—-nothing happens when I click ‘References’. I have restarted. I have emailed the files from the VMWare environment to myself, and they don’t work. I have enabled all macros and data connections by selecting those radio buttons, but still have VBA throwing that error and my macros disappearing until I reopen the file.
I truly don’t understand. Can somehow the files be corrupted only when I access them from home? Is there any fix?

Launch one addin from another addin in excel

We have developed a couple of excel addins with office-js and are finding that it would be really handy to be able to launch one addin from another addin and even possibly pass some data between the 2. Is the launching at least possible?
If you own both add-ins, you could navigate to one or the other via the URL's you placed in your manifest file. This could allow you to launch another add-in, however it would be inside the same task pane.
You could also pass data between both apps via url query parameters.
I've done this before when I made an add-in that was a landing page for other add-ins. When you clicked on a button for another tool, it would navigate to another add-in (which was a separate project) and pass the previous tool as a parameter in the URL so you could navigate back to where you came from.
It'd also be possible to share data on a private sheet inside Excel.
This would be security issue when an add-in will be able to manipulate others. For this obvious reason this is not possible.
Usually I advise to use https://officespdev.uservoice.com/ to request unimplemented feature, but based on your description, Office team most likely won't allow it anyway.

Open an Excel file in running instance of Excel with Task Scheduler

I use Task Scheduler to automate a variety of nightly tasks using Excel. Typically the task opens a new instance of Excel, which in turn opens a specified file, which does some stuff and closes itself (and Excel).
Now I have a task that requires an add-in, and use of the add-in requires separate authentication. There is no way to pass my credentials - I have to manually authenticate when the add-in loads. Because the old-fashioned way always launches a new (unauthenticated) instance, I can't figure out how fully automate tasks that require the add-in.
One workaround would be to open an instance of Excel before I leave, authenticate for the add-in, and leave that instance open. Then I could theoretically schedule the opening of some file within that instance (as opposed to launching a new instance to open the file, as described above) and do whatever the tasks were that required the add-in.
Is it possible to do this, either directly by defining the task a certain way, or in a .bat file that I can run on a schedule?
I have a very similar problem and wondering if you have solved this problem through the VBA (getobject(), sendmessage method etc) yet.
I created a seperate question on this just show what I have done. Windows FindWindows and SendMessgae for Auto-authentication excel VBA
Basically I am stuck on how to pass user name and password to the add-in pop up window.
Thanks a million times:)

Unable to create Excel macros on particular machine (possible Windows Group Policy issue?)

I have a Windows 2003 Server box with Excel 2010 installed, upon which I am unable to create new or execute existing macros in spreadsheets. Note: this machine is in a Windows Domain (and I am not getting much help from the network folks here.)
I can and have edited the macro security levels within Excel (File, Options, Trust Center, Macro Settings --> Enable All Macros) but despite this, when I try to:
Open a spreadsheet with macros, I get an exception "Excel found unreadable content...." which goes on to refer to the VBA macros within the spreadsheet
Create a new macro in a brand new spreadsheet created on this machine, all the toolbar buttons providing access to the VBA editor are disabled.
Could this be a Group Policy setting that allows me to edit the macro security settings, but overrides these settings and prevents me from actually creating, editing, or executing VBA macros? (If so, does anyone happen to know which group policy setting I should be looking for?)
I've run rsop.msc (Resultant Set of Policy) on the machine and looked through every single thing under both Computer Configuration and User Configuration, but I don't see anything related to Excel (or Office) Security/Macros.
In this case, the problem was that Visual Basic for Applications hadn't been installed when Excel itself was installed.
(As usual, Microsoft could do a much better job of alerting the user to this unusual configuration, but what can you do.)

Resources