Problems using Analysis for Office functions - excel

When we try to run analysis for office functions such as:
lresult = xlApp.Application.Run("SAPLogon", "DS_1", bw_client, bw_user, bw_password)
lresult = xlApp.Application.Run("SAPExecuteCommand", "RefreshData")
Despite analysis add-in is active in our workbook and all macros are enabled (trust center...), we always get the same error: Cannot run the macro "SAPExecuteCommand". The macro may not be available in this workbook or all macros are disabled.
Has anyone any idea to solve this? I´ve tried to add all SAP libraries in Tools/References, however it doesn´t work.
Thank you so much

You should have a look at the following registry key:
Computer\HKEY_CURRENT_USER\SOFTWARE\Microsoft\Office\Excel\Addins\SapExcelAddIn
If the value "LoadBehavior" is set to something different than 3, the described error will occur because the COM Add-In is not loaded. If you set it to 3 ("The Add-In is enabled. If required, users can disable it in the COM Add-In dialog box."), the error should disappear.
See the SAP documentation for details on "LoadBehavior":
https://help.sap.com/viewer/df90d3701aba42b9a4351caa387bd672/LATEST/en-US/f26e8ad16c9b1014bf2c9a7eb0e91070.html

Related

User unable to open or save workbook with VBA code

This has me stumped. The user is able to work with workbooks containing the same code that were produced previously. Just recently new workbooks with the same code in them cannot be opened or saved. There are a range of error messages depending on where the workbook is opened from - we have tried safe locations, local folders and Dropbox folders. We have also tried with code signed and unsigned workbooks.
Error messages include:
'Excel cannot open the file Test.xslm because the file format or extension is not valid...' (not true, as I can open the same workbook and run the code without problem).
'Your changes to Text.xlsm could not be saved due to a sharing violation...' (followed by more errors to do with not finding a temporary document).
I have also tried removing ActiveX references which might flag as a security issue, (e.g. VBIDE) and commenting out blocks of code. No joy. Microsoft Defender reports no issues. There are no other antivirus programs running. There are no problems with the same workbooks with the VBA modules removed completely - so it definitely looks code related.
Anyone have any ideas?
This might be because of ASR.
If you check your "Windows Security" --> Virus & threat protection --> Protection history, you should find an event of "Risky action blocked" that shows your file has been "Blocked by: Attack surface reduction" Rule: Block Win32 API calls from Office macro".
I'm currently facing a very similar issue but I'm on the other side (I am the one that enabled ASR rules).
If that is the case for you as well, I wonder whether the problem depends on the identity that you use to save the file through your macro. Are you using the same security context of the user executing Excel?

Error handling for excel addin that cannot find networking drive

I have made an addin and placed it on a shared networking drive.
The addin contains a seperat sub that calls the addin whenever an excel document is opened, so the addin will be available in excel all the time.
The addin works fine when i am in my office and when i am connected, however if i for example work from home, and opens excel, then excel gives me the following error:
"Sorry we couldn't find . Is it possible it was moved, renamed or deleted?"
This is because i am not connected and excel cannot retrieve the path i am trying to call the addin from.
Is there a way to handle this error, so the message dont show up? I have tried to ignore the error so the message dont show up but that does not work. How can i exit the sub before the error appears? or an even better solution is to call custom made addins without using a specific networking drive as location.
I have tried the following code to ignore the error.
Sub Open_up ()
Application.DisplayAlerts = False
On Error Resume Next
Call 'name of the addin
End Sub ```
Hope it makes sense
It looks like the add-in was not loaded and not accessible from the shared drive. I'd suggest creating an installer for the add-in, so it could be installed on the end user machines. See Deploy an Office solution by using Windows Installer for more information.

SAP Business Objects Financial Consolidation Excel Add-In Automation

I have a SAP Business Objects Web 7.5 Add-in in Excel 2007.
The add in itself is made up of a compiled .xll file (CtExcelLinksWeb.xll) and a number of dll's.
A bit of vba shows the xll is registered, and all of its registered functions.
However, when I try to use one of these functions in VBA using Application.Run(), I get
Runtime 1004 - Macro may not be available or may be disabled.
I have tried registering the xll within the same sub (Application.RegisterXLL ()) and upon registering a VBAProject called CtEmpty.csv is created
I want to be able to automate the use of this add-in using VBA as it does long winded repetitive tasks, and then I can work on figuring out how to use the functions
Any help will be appreciated
Are the DLLs on the PATH? It may be that Excel can't load the DLLs that the XLL is dependent upon. Dependency Walker (depends.exe) is a handy tool for troubleshooting this kind of issue.
Also, have you tried using File/Options/Addins to register the XLL, as well as VBA code?

Add-ins not loading when opening excel file programmatically

I've seen some similar problems described by others before but no real solution. And I'm sure there is one.
I have a .XLA-add in configured to be loaded when I open up Excel. It works fine when I open documents or Excel it self. However, when my BI-system programmatically creates and opens an Excel-file the add-in does not get loaded. The BI-system opens Excel in a new instance so it does not help to have opened Excel on beforehand (and thereby the .XLA-add in)
If i Check Options-Add Ins it looks like the add-in is loaded but it is not!
What I've tried (and that does work) is to insert this function into the created excel-file and "reload" the add-ins, but I want to find an automated solution!
Function ReloadXLAddins(TheXLApp As Excel.Application) As Boolean
Dim CurrAddin As Excel.AddIn
For Each CurrAddin In TheXLApp.AddIns
If CurrAddin.Installed Then
CurrAddin.Installed = False
CurrAddin.Installed = True
End If
Next CurrAddin
End Function
Is there any way to load my Add ins automatically when instancing excel programmatically?
Any tips, solutions or workarounds are highly appreciated!
Best regards.
This may not be possible in VBA. I have come across this problem before, and used the implementation found here: Excel interop loading XLLs and DLLs
However, that solution is for C#. The steps required may not be possible when coming from inside of an Excel VBA script. Perhaps there are some VBA implementations you can look at, but wanted to give you some sort of starting place because I know that is a frustrating place to be.

How do I enable an Excel Automation Add-in through the registry?

I have an Excel Automation Add-in that is registered with COM by my installer. By registering with COM, my add-in appears in the (for Excel 2007) Excel Options > Add-Ins > Manage Excel Add-Ins Go... > Automation list. The users must still navigate to the dialog above and select my add-in to enable it.
Is it possible (via a registry key perhaps) to enable my automaton add-in programmatically in my installer class (or in VBA) after the types are registered with COM?
Thanks in advance - Frank
Ive not done ths specifically, but a reference that I use has this to say regarding your question:
Automation Add-Ins are loaded in the same way as normal .xla Add-Ins , but using the ProgID instead of the file name, as in the following code:
Sub installAutomationAddIn()
AddIns.Add Filename:="Excel2007ProgRef.Simple"
AddIns("Excel2007ProgRef.Simple").Installed = True
End Sub
If you are creating an installation routinefor your Add-In, you may want to write directly to the registry in order to set the Automation Add-In as installed. To do so, you need to create the following registry entry (Which will already exist if you've used the above code).
(In the Registry Key:)
HKEY_CURRENT_USER\SOftware\Microsoft\Office\12.0\Excel\Options
(Create the string value:)
Name = the first unused item in the series: Open, Open1, Open2, etc.
Value = /A "Excel2007ProgRef.Simple"

Resources