ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   What is VB_Invoke_Func attribute? (https://www.excelbanter.com/excel-programming/285034-what-vb_invoke_func-attribute.html)

Jag Man

What is VB_Invoke_Func attribute?
 
I would like to import VBA modules generated by another application into
Excel. That is,
I want to create the module as ordinary text file using VC++. I exported a
module
created in the VB Editor (opened from Excel Tools|Macros menu) just to see
what it
looked like. When I open it in a text editor (e.g., Notepad) I see the
following:

' Declare myFunct as a C++ function in a DLL
Private Declare Function myFunct Lib "myDLL.dll" _
(ByRef inArgs As Double, ByRef outArgs As Double) As Long


'Define a Sub that calls myFunct
Sub myFunctDriver()
Attribute myFunctDriver.VB_ProcData.VB_Invoke_Func = "m\n14" <-----
WHAT IS THIS???
Dim inArgs(1) As Double, outArgs(1) As Double
Dim ec
inArgs(0) = ThisWorkbook.Worksheets("WS1").Range("b6").Value 'x
inArgs(1) = ThisWorkbook.Worksheets("WS1").Range("b9").Value 'y
ec = myFunct(inArgs(0), outArgs(0))
If ec = 0 Then
ThisWorkbook.Worksheets("WS1").Range("h4").Value = outArgs(2) 'z
ThisWorkbook.Worksheets("WS1").Range("h5").Value = outArgs(1) 'w
End If
End Sub


This is exactly what I see in the VB Editor with the exception of the noted
line (<----- WHAT IS THIS???).
Since I did not type it, VBA must have inserted it, but hides it from view
in the VBA IDE.
Where does VB get the "m\n14" string? Is it just an arbitrary unique string
for each defined function?


TIA

Ed



Vegan55

Quote:

Originally Posted by Jag Man (Post 1006656)
Where does VB get the "m\n14" string?

The m part means that Ctrl+m is the shortcut key for the macro or function.

The n14 part means that the macro or function is in the numbered category 14. Which is "User Defined" functions.

As another example, I have a function which has VB_Invoke_Func = " \n3" specified in it. This means there is no shortcut key and the function is in numbered category 3, which is "Math & Trig" functions.


All times are GMT +1. The time now is 08:22 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com