I want to run integrated VBA functions like VBA.RGB() with the Application.Run() command. This method is stored in C:\Program Files (x86)\Common Files\Microsoft Shared\VBA\VBA7.1\VBE7.DLL
According to this Microsoft article, running methods stored in a DLL should be feasible with Application.run: https://docs.microsoft.com/en-us/office/vba/api/Excel.Application.Run
But how exactly may I do this? None of the code lines below are working.
Sub RunFunction()
Dim ExampleValue As Variant
ExampleValue = Application.Run("RGB", 1, 1, 1)
ExampleValue = Application.Run("C:\Program Files (x86)\Common Files\Microsoft Shared\VBA\VBA7.1\VBE7.DLL!RGB", 1, 1, 1)
ExampleValue = Application.Run("VBE7.DLL!RGB", 1, 1, 1)
ExampleValue = Application.Run("VBE7!RGB", 1, 1, 1)
End Sub
I would like to avoid wrapping all these standard functions into some module functions.
Edit - To further specify my question:
At the end of the day I would like to create a CallByName-like function that is capable to run integrated VBA functions from a function name given as a string. CallByName requires an object to invoke methods or properties. Example: CallByName Workbooks, "Add", VbMethod You may not invoke VBA methods this way. CallByName VBA, "RGB", VbMethod, 1, 1, 1 would not work.
Dim x As New Your_Dll. And then useExampleValue = x.RGB. Supposing that such a method, returning something exists in that specific dll. - FaneDuruVisual Basic for Applications, indeed... - FaneDuruDim V as VBAdoes not work since "VBA" is not an actual data type. But maybe I got you wrong there? How may I declare a variable as a DLL otherwise? I could useprivate declare function ... lib ...to add every single function from that DLL but thats pointless since these functions are available by default anyway. Furthermore I could wrap all these functions into self written module functions but thats something I would like to avoid. - GuidoT