I am trying to use an excel add in in VBA. Unfortunately recording the macro doesn't seem to work and hence the reason I want to try use the keyboard shortcuts. The shortcut I am after is ALT X 2 V. I have tried using SendKeys.send ("%{x}{2}{v}")
but every time I try to use it, the code write the values "2v" to my vba screen. I am not sure I have fully understood how to use this method as I want the actions to be actioned in excel so that I can access this add in.
I have been through the forums but can't seem to get an answer, which includes putting a wait command between each keystroke. Could really do with some help.
Try SendKeys "%x2v"
That said, using sendkeys is almost always a Bad Idea. I understand that you're trying to call some function from an addin, but if you're able to access that code at all, I would do so, and call whatever you're trying to run directly. At some point, SendKeys will mess something up.
Related
Have created a Macro - multiple subs, functions and forms for Solidworks.
I'm sure the code is dubious but it works when I force it to start in main()
When I add a button in Solidworks to start the macro it defaults to a different sub, which appears to be alphabetical, I get a similar behaviour starting the macro from the editor.
It appears all the subs listed are the ones with no arguments passed in.
Could anyone please guide me on why this happens? I'm sure I could frig a way around by renaming the subs, but don't realy want to.
It appears I was to impatient, again!
When adding the macro button in Solidworks you are given the choice of choosing the sub to run ... as Method
I was wondering if there was a way to pass UDF's instantly instead of "Entering" the function during step-through debugging. I commonly use functions that I know are fully working, and I often don't want to enter each one when I'm debugging. This is even more annoying when you pass multiple functions as arguments and have to enter each one before you get a return.
This question came from me frequently using things such as Application.WorksheetFunction.functionName and wanting to create a function that did the same exact thing and would also pass instantly, but with a shorter name.
Is there an option in VBA or perhaps an Application.Setting or Option Setting that I could use for this? The difficulty here would be that I only want this on some functions, not all..
Thank you
1) Put a breakpoint after your function as shown below:
2) Debug using F8 till the line with "myFunction".
3) Press F5 to jump to the breakpoint (by executing the current code).
You can put multiple breakpoints and jump multiple times to the next breakpoint using F5 in your code.
I was given a template for report (.dotm) with alot of vba code behind that gets data from a mssql database and writes the data at some bookmarks.
Unfortunately, the code has an error and I have to fix it.
Since I have never done vba before, I'm a bit lost.
There is a function with 2 parameters that does everything.
Can you tell me how I can debug this function?
I have set a breakpoint to the first line but how can I tell word(?) to execute the function?
My first approach was to add a button and set the onclick event to this function. But unfortunately macros are disabled by our policy and this doesn't work :(
Can you please help me out how I can get inside this function?
How can anyone expect the code in the template to work if macros are disabled?
Try ALT+F11 to get into the VBA environment and show the code. Put the cursor in the code you want to debug and press F8 to step into it or F5 to run it to any breakpoint.. If the code you want to debug has parameters, you have to write a dummy Sub to call the function with test-parameters.
Also, see sams comment about the trust center. Maybe you can change the settings yourself to allow macros.
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").Controls.Count).Execute
which simply executes the last control. Also this should work by the control caption:
Application.Commandbars("Cell").Controls("the button caption").Execute
Is it possible to create a macro in MS Office (in this case Word) that will change other macro code? I was trying to find information but no results.
I have a doc which works as a template. Content of template is changed and then saved to another file. However it is important to have current date in it. It cannot be self-updated. Those docs go to folder of people and it is important to know when they get the document, so it must be simply data (or something that does not update).
I was thinking about an on-start event macro that would input current date and on exit it would ask "Do you want self-update functionality" Yes / No
If Yes, delete that event. However I have no idea if it is possible. If it is I still don't know how to search for it.
No this is not possible. In VBA, unlike some lower level languages when you define an event you can not disable it, even using other VBA code.
In C# or VB.NET, Java or C++ you can disable an event by un-wiring it from the handler, but this is not possible in VBA.
Maybe if you be more clear on what you need I can give you a better answer.