Excel Add-ins installed programmatically are not loaded - vba

Question Summary:
Why do my add-ins which are installed programmatically do not load when I start Excel from Program Menu but are loaded when I open the Installer.xlsm workbook which installed them?
Details:
My team develops a hierarchy of add-ins used by various users in our organization.
I have an Installer.xlsm file which installs new versions for each of the add-ins. It has a Workbook_Open method which upon opening the workbook uninstalls currently installed versions of the add-ins and installs their newer versions.
This worked wonderfully for over a year. Recently we updated the hierarchy of the add-ins and since then the same script would run successfully, uninstalling old add-ins and installing new ones. However, when Excel is re-opened (from program menu or an existing workbook) it seems that the script had no effect at all - the add-ins that were installed before the run remain installed and the new add-ins are not even listed in the Manage Add-ins form. This is reflected also in HKCU\...\Excel\Add-in Manager - the list of add-ins remains identical to what it was before the run.
However, if I open Installer.xlsm again - it loads only the add-ins I'd expect it to load after a successful script run (loads the newly installed add-ins and doesn't load the ones the script uninstalled)! It's as if the add-ins are installed in the scope of the single .xlsm file...
Notes:
The add-ins are not placed in Excel's Add-in directory but in a project folder (C:\appname\Addins\date).
I use Excel 2010 on Windows 7 and have admin privilege on my machine.
It's not a matter of Registry write access, since the same add-ins, if installed using the Excel UI are registered correctly under HKCU\...\Excel\Add-in Manager.
Please help resolve this mystery!
Code section which does the uninstalling:
For Each ad In Application.AddIns
For Each appName In pAppNames
If pIniMap.item("FilePrefix").Exists(appName) Then
filePrefix = pIniMap.item("FilePrefix").item(appName)
If Left(ad.Name, Len(filePrefix)) = filePrefix Then
If ad.Installed Then
ad.Installed = False
Workbooks(ad.Name).Close False
End If
End If
Else
logger.Warn "Entry is missing for section FilePrefix, appName=" & appName, methodName
End If
Next appName
Next ad
Code section which does the installation of the add-ins:
For Each file In addinFiles
curAddInPath = pAddinDir & file
With Application.AddIns.Add(fileName:=curAddInPath)
.Installed = True
End With
Next file

It may be that your adding from the default directory rather than the custom directory you specified. I added the argument below, in your installation code. Hopefully it helps.
For Each file In addinFiles
curAddInPath = pAddinDir & file
With Application.AddIns.Add(fileName:=curAddInPath, CopyFile:=False) 'add false to args if addin is not coming from default directory
.Installed = True
End With
Next file

Related

adding Powerpoint Add-in from registry throws " Powerpoint couldn't load the file" error

I created Powerpoint Add-in using VBA. I added it manually to Powerpoint and it works fine, When I start Powerpoint, I can see it's loaded and working as expected. I want this add-in to load through registry. Below is my registry file detail. But it throws error "For some reason Powerpoint couldn't load the file"
#
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Software\Microsoft\Office\15.0\PowerPoint\Addins\MyNewAddIn]
"AutoLoad"=dword:ffffffff
"Path"="file:///C:/MyAddinFolder/MyNewAddIn.ppam"
FWIW, here's the registry entry for one of my installed add-ins:
[HKEY_CURRENT_USER\Software\Microsoft\Office\15.0\PowerPoint\AddIns\RESIZE]
"Path"="C:\\Users\\steve\\AppData\\Roaming\\Microsoft\\AddIns\\RESIZE.PPA"
"AutoLoad"=dword:ffffffff
Yours:
[HKEY_CURRENT_USER\Software\Microsoft\Office\15.0\PowerPoint\Addins\MyNewAddIn]
"AutoLoad"=dword:ffffffff
"Path"="file:///C:/MyAddinFolder/MyNewAddIn.ppam"
Note the differences in the Path entry.

Unable to add excel add-in for all users

We have an application which shows up as an Excel ribbon.
We have installed the application in our test environment through administrator login. We are trying to make a per machine installation.(Please note that in production environment, the installation will be through system account).
When we login as user to the same PC, we don't see the excel addin in the Excel ribbons. We don't see the addins anywhere in the list of addins as well.
We have tried using Active setup,Userstat,setting the values of properties as ALLUSERS=1, RegisterForAllUsers= True, InstallScope= perMachine, InstallAllUsers = Everyone, RunActionsAsInvoker = True . Also the privileges has been changed from user to admin in all the cutom actions and in manifest file as well. All these changes where made as we understood that the application used to package is Addin express and so the msi creation with privileges as admin is possible.
Unfortunately none of these changes seems to help us.
What we would need is an msi which we can install on per machine basis.
From the situation mentioned in the question, we had tried a lot of options and finally following approach works for us:-
Create a package which would place a powershell shortcut in the startup folder.
The shortcut would in turn call or execute a powershell script.
The powershell script would
1. check if the registry key for that particular add-in is available in HKCU.
We had our registry key as "HKCU\Software\Manufacturer Name\Product Name" which in turn had a string value "Installed".
If the registry key is not available for the user, then install the package with tranform.
3.If the registry is already available, then script doesn't make any change.
The package is installed as an Admin and once the user logs in, then automatically the cmd file is executed and the add-in is installed.
Since this was the first version of the product, we didn't have to handle version compatibility.

Run-time error 429, ActiveX component can't create object, automate MS Word application, CreateObject("Word.Application")

I'm running into the following error when executing the following line from VBA (Access):
Set wd = CreateObject("Word.Application")
I found the following link, but did not find it useful: http://support.microsoft.com/kb/828550
Things I've Tried
Repair installation of Office from Control Panel > Programs and Features
Uninstall MS Word, re-install
Tried Dim wd As Object instead of Dim wd as Word.Application
Manually run Word.
Run winword.exe /RegServer in Administrator command prompt. Did not run silently, merely opened Word.
Examine the LocalServer32 key under the CLSID {000209FF-0000-0000-C000-000000000046}. Initially was missing. After re-install Word, the CLDID was there but LocalServer32 key is missing.
Run winword.exe /automation. Merely starts Word.
Run winword.exe as Administrator.
Run access.exe as Administrator.
Relevant (maybe)
Windows 8 x64
Office 2007
C:\Program Files (x86)\Microsoft Office\Office12
A preview version of Office 2010 was pre-installed.
Launching Excel works with automation and VBA.
asycfilt.dll file version: 6.2.9200.16384, date: 7/25/2012 11:05pm
oleaut32.dll file version: 6.2.9200.16384, date: 7/25/2012 11:06pm
olepro32.dll missing
stdole2.tlb no file version, date: 7/25/2012 10:34pm
McAffee anti-virus
Examine the LocalServer32 key under the CLSID {000209FF-0000-0000-C000-000000000046}. Initially was missing. After re-install Word, the CLDID was there but LocalServer32 key is missing
So Word is unable to register properly because you have a system issue.
As that you've tried most or all of the reasonable steps, your next step is to reinstall Windows.
Or you could try manually registering it by duplicating all the relevant keys from a different machine. But that probably wouldn't solve the problem.
Super User might be a better place to ask about installation and Windows registry issues.

Microsoft Office Excel cannot access the file

I have create Office Excel application in my machine(XP). and i have placed the application in windows server 2008 giving the following error.
Microsoft Office Excel cannot access the file '\server\Input.xls'. There are several possible reasons:
The file name or path does not exist.
The file is being used by another program.
The workbook you are trying to save has the same name as a currently open workbook.
both client and server systems installed office 2007 and added reference microsoftexcellibrary 12.0
created assembly for the application and calling the code from the form.
I was getting the exact same error, although in my case I was trying to run (from Tidal Enterprise Scheduler) a .NET app that used microsoft.interop.excel.
The answer is already in stackoverflow:
[Microsoft Office Excel cannot access the file 'c:\inetpub\wwwroot\Timesheet\App_Data\Template.xlsx'.
I'll re-list the steps from that link:
Create directory “C:\Windows\SysWOW64\config\systemprofile\Desktop” (for 64 bit Windows) or “C:\Windows\System32\config\systemprofile\Desktop” (for 32 bit Windows)
Set full control permissions on Desktop directory above (for example in Win7 & IIS 7 & DefaultAppPool set permissions for user “IIS AppPool\DefaultAppPool”)
Of course, if you're running a scheduled task rather than WebApp, you'll need to make sure the service account you're using has permissions on that folder.
I had the same error when trying to save to:
C:\test.xlsx
When attempting to save to the root directory, it seemed to cause problems. Changing my path to:
C:\MyExcelTests\test.xlsx
Worked fine
I would make sure no Excel processes are running on the machine before you run this application, that should cover the last point.
The first point looks the most likely issue, the path looks like a partial path or an incorrect UNC path. Try putting the full path to the spreadsheet 'C:\server\input.xls' and see if that works.
To stop the middle point, in the workbook.open command you can specify to open as read-only, this will make sure the application can red the file even if it is locked open by another user.

Running VBScript from UIAccess VB app using MSScriptControl

I'm trying to run some VBSCRIPT from within my application. This works fine when I run my program from within VB. But once I add "UIAccess=true" to my manifest and digitally sign my exe with my certificate, I am unable to run the code any more. It gives errors when I try to interface with any program saying "429: ActiveX component can't create object: 'myApp.Application'". Anyone have any idea why it would run fine in the IDE but not with an application with uses UIAccess? Here is the code:
Dim scriptRunner As New MSScriptControl.ScriptControlClass
scriptRunner.Language = "VBScript"
scriptRunner.AllowUI = True
scriptRunner.Timeout = 3000
scriptRunner.AddCode(scriptStr)
scriptRunner = Nothing
In googling around, I found this website.
it says
Applications with the uiAccess flag set to true must be Authenticode signed to start properly. In addition, the application must reside in a protected location in the file system. \Program Files\ and \windows\system32\ are currently the two allowable protected locations.
maybe it works in your IDE because your IDE is within \program Files\, but outside of your IDE you are running the signed application NOT within \program files or \windows\system32