Hi Rob,
That does not look like something you can do easily as a function that would be called from a worksheet formula.
You might rather launch the process from a ribbon button or a shortcut key, or even a button control that you put on the workbook.
For these case you would make a “Shared Sub” which can then look at the ActiveWorkbook, and pass that on.
You can make full ribbon extensions with Excel-DNA (see https://github.com/Excel-DNA/Tutorials/tree/master/Fundamentals/RibbonBasics and https://www.youtube.com/watch?v=2oBQaQFgQow) but the easiest is just using the <ExcelCommand> attribute like this:
<ExcelCommand(MenuName:="My Menu", MenuText:="Start Linking")>
Public Shared Sub StartLinking()
Dim app As Application
Dim wb As Workbook
app = ExcelDnaUtil.Application
wb = app.ActiveWorkbook
Dim obj As New TripDoc
obj.Start_Linking(wb)
End Sub
You should find the menu entry under the AddIns tab.
You can also assign the “StartLinking” macro to a button you place on a workbook using Developer -> Insert -> Form Control.
-Govert
--
You received this message because you are subscribed to the Google Groups "Excel-DNA" group.
To unsubscribe from this group and stop receiving emails from it, send an email to exceldna+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/exceldna/8a0a8298-f446-44b0-973f-563529cf46ccn%40googlegroups.com.
Hi Rob,
It’s not about the programming language, in this case, but rather about Excel distinguishing between “worksheet functions” and “macros”.
There is no problem in VB.NET making a Sub that takes parameters, and such a Sub can even be registered as a “macro” with Excel, though that’s unusual.
Excel-DNA matches this distinction in how it registers your methods with Excel, according to the <ExcelFunction> or <ExcelCommand> attributes.
The restrictions from Excel are these:
So I redirected you from a Function marked as <ExcelFunction> to a Sub marked as <ExcelCommand> taking no parameters in order to register the procedure as “macro” and give you an easy way to call it.
To view this discussion on the web visit https://groups.google.com/d/msgid/exceldna/d7a88257-047d-459c-b1f8-e3aa9672dc1en%40googlegroups.com.