Run a 3rd party Excel Add-in from VBA - vba

I want to programatically run a 3rd party Add-in with VBA alone. Im using Excel 2010
Ideally, I'd like to be able to call the functions individually however I don't have any access to the code of the Add-in (it doesn't even appear as a password protected VBA Project it did in Excel 2003).
Hours of Googling has told me this was possible in earlier versions of Excel, either through Application.CommandBars("Add-Ins").Controls("Custom Button").Execute or CommandBars.ExecuteMso("Custom Button") - AFAIK, the latter now only works with in-built functions.
This custom button also appears in the 'Right-Click' menu so could possibly be run with some sort of SendKeys implementation. This is however, clearly far from ideal.
I'm pulling my hair out over this - any help would be greatly appreciated.

Depending on how it has been added to the menu, this may work:
Application.Commandbars("Cell").Controls(Application.Commandbars("Cell").Contro‌​ls.Count).Execute
which simply executes the last control. Also this should work by the control caption:
Application.Commandbars("Cell").Controls("the button caption").Execute

Related

Why would an Access 2010 form button with an embedded "openreport" macro and a "where" filter, stop working until I add a new button?

I decided to "tweak" an existing database to further manage multiple sources of income.
I copied the working database and created a "modification copy", just in case I messed things up horribly.
In the modified version, I have a button on a form (in fact, two different buttons with similar macro properties, just directed to do the same function to different reports.
The properties are your standard macro with an openreport, and a "where" condition.
Here's the problem. The macro has worked in the past, and continues to work on my "pre-modification" operating database.
On the modified database, after ensuring all the parameter elements are entered correctly, I can change the "view" to report view, and the macro seems to work just fine until I close the database.
As soon as I open the database, the buttons produce an error. See pic below.
The only way I seem to be able to resolve this odd button macro issue is by going into design view and adding a new button. I've discovered...I don't even need to embed a macro, just adding a new button seems to renew the macro operation...until I close and reopen the database. Then, I have to add a new button again to get the open database's macro to operate.
I can delete the new button added, and still have the macro buttons work, until I close and open the tweaked database.
I have zero VBA coding knowledge. I use Access's macro building tools and typically have to visit sites like this if I need to learn a new "trick" to get my database and it's various tools to do something.
I recently explored with the "subform" that can be seen above in the open form pic with the error message. My guess is that maybe that subform is somehow causing my macros to continuously fail???
Thanks for any help!

Is there a way to package add-ins so that users only have to click one to use all macros within it?

I've got a dozen macros that have 90% similar code. I've created 4 sets of VBA in an add-in file so that I don't have to revise a dozen different places any time a change needs to be made. The plan is to end up with:
specific code
universal code A
specific code
universal code B
The users are not particularly tech-savvy so I want to make the distribution as painless and idiot-proof as possible.
Also, the add-ins don't have to be visible--no one is going to run them on their own, they're just going to be embedded and called upon from other macros.
I've looked around online and the closest thing I've found is this How to combine multiple VBA macros into one add-in file for Excel
It still looks like this is geared more towards having multiple buttons, which I really don't need (or want...I don't actually want ANY buttons)
Not really sure what kind of code I could show to help with this problem, since I don't know if this is even possible to do.
Once you save the XLAM file you just have to click on Excel Add-ins under the Developer tab, browse to the folder where it is stored, and open. It will then appear as an add-in package that you can click on.

Launching VBA Applications blocks working with and opening other workbooks

I developed a vba application in excel for a company, They wants to leave it open the whole day until the end of work hours, while working normally on other excel workbooks.
The application is working just fine, no problem with the code.
My problem is that when the application is launched .. it blocks the other opened workbooks (I can't select cells or do anything).
And also If I try to open a sample excel file while the application is launched, it won't open.
(I tried with a simple userform and still the same problem, so the problem doesn't have anything to do with my application)
Is this something normal in Microsoft Excel, because I can't find anything on the net that is similar to my problem ?
Thanks in advance ..
Sounds as though you have a userform displayed modally (which is the default way of displaying a form). If you need to have the form displayed all the time you can display it modeless, but note that this does not work well with Excl's SDI implementation: you have to use Windows API calls to keep the form from being hidden. see http://www.jkp-ads.com/Articles/keepuserformontop01.asp
Alternatively you could change the design to use a ribbon command to display the form only when needed.

How to add vba code in ms access

I am using web app, and I want to add the vba code after I update the Open date.
but when I click after update, I can just add macro, there is no vba code options.
I google it but I can't find any property sheet even I click right. How can I add the vba code there?
You can't. Access web apps don't support VBA code. There is no way to work around that, to my knowledge.
You can always migrate to a normal database.

How to update an Access VBA app with 30 forms?

I need to update an Access VBA app with around 30 forms in it.
I have to amend a screen that seems to have been set up right at the start of the app, it uses a lot of SQL tables. Is there an way of finding my way to the start of the code?
I come from a procedural coding background and I am unused to code that doesn't have a start and an end; I also know a bit of VB, some ASP, some .Net and general computing.
When something "automagically" happens upon opening an Access database, it is almost always because
A "startup form" has been specified. (In Access_2010 that's done in File > Options > Current Database > Display Form.) ...or...
The database has a Macro named AutoExec which is automatically run when the database is opened (unless you bypass it by holding the [Shift] key down while opening).
In addition to #Gord's answer, there's a few things you need to know. I'm going to give you the quick & dirty version.
First, there's 2 types of code in Access. VBA & macros. Sometimes what's called a macro, is really VBA.
In Access, a macro is a set of instructions to do something to the database. It's very limited in what it can do. These are often used by novices who don't know how to program in VBA.
VBA is the real powerhouse behind the scenes. It can do everything a macro can do, but a whole lot more.
Access uses an Event-Driven / Object-Oriented (at least close enough for this discussion) interface. Do a Google search on those meanings. But very quickly, the listbox on a form is an object. It has properties (like width), methods (add an item), and events (click on an item).
To see the code, for macros look to to your navigation window to your left. For VBA (modules), look to the same window, or just press Alt-F11. VBA can be used standalone in a module, or behind the scenes of a form or report.
Once you get the hang of it, you'll find Access to be a handy RAD tool for small projects.
Good luck.
It appears that you already have found the form that opens when the app starts (if not, check out Gord Thompson's answer).
The first things that happen when an Access Form opens (the "start of the code", as you called it) are the Load and Open events.
If there is any code in this form that is connected to these events, then it's in the Form_Load() and Form_Open() functions in the code of the form.