Application.ScreenUpdating with calling functions from a plugin in Excel VBA - excel

I am writing several big macros that reference a Salesforce.com Add-in called Sforce Connector. The functions in the plug-in don't seem to have Appication.ScreenUpdating set to False so the execution of the code is slowed down. I can't change the code of the Add-in, so I can't change the status of Application.ScreenUpdating. Is there a way to set it globally for a file or are there other ways of getting around this?

Related

Prevent Excel custom function running on file open

I am building an Excel add-in with many custom functions. They work fine, however, when I close and reopen the file, all functions are recalculated. Since each custom function makes an API request to my website and the data does not change frequently, I am looking for a way to turn this feature off so that functions do no rerun on file open. I have looked through all the docs but could not find any answers. Really appreciate if someone could help me with this.
My add-in will be used by other users so I am looking for a solution that does not require any extra action from the (like setting the calculation mode of the spreadsheet to manual)
You can set up the manual calculation in the following way:
Application.Calculation = xlCalculationManual
Application.CalculateBeforeSave = False
The XlCalculation enumeration specifies the calculation mode.

Problems using Analysis for Office functions

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

Add external libraries using code in VBA for Excel

I am trying to add external libraries and use them in VBA for Excel. I have found two questions about it, but I can't get them to work in a real application.
Both of them work fine on their own, but when I try to use them in a program I get a compiler error. It seems that I cannot compile the program before I add the library (makes sense, I use unknown objects) and I cannot add the references before I compile the program.
How can I solve this?
Question 1:
Connect references (Tools>References) with VBA code (macros)
Question 2:
How to add a reference programmatically
It seems the references can be added using the Workbook_Open sub in Excel. This sub automatically runs when the workbook is opened. It works fine if it does not call any routines that use objects from the libraries that need to be added.
One of my concerns was that the macro would not run if the user has to enable macros after the book is opened. Most of the information I can find indicate that it should still run. I have not been able to test it yet though, because it seems very difficult to "untrust" a workbook to has been set to "trusted" before.

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.

Resources