Have a function return a Hyperlink

Sep 4, 2011 at 5:50 PM

Is it possible somehow to have an Excel-DNA function return a hyperlink?

I've tried with:

[ExcelFunction(Description = "", Category = "SeoTools")]
public static object Foo()
{
return object XlCall.Excel(XlCall.xlfHyperlink, "http://www.google.se", "Bar");
}

But this only returns the string "Bar".

Best regards
/Niels

Coordinator
Sep 4, 2011 at 6:13 PM

Hi Niels,

The Excel C API does not have any datatype that would allow the magic "HyperLink" to be returned.

If it were a macro that you run from some ribbon button, you could presumably set the formula of the cell to be =HYPERLINK(...).

I suspect the "HYPERLINK" function is one that Excel checks for internally and processes in a special way. Similar to =TODAY(), which reformats the cell to a date format automatically. Our user-defined cannot behave the same way as these built-in functions.

The only workaround would be to fire off a macro that runs after your function has completed, to reformat the cell. I would not recommend going down that road incautiously.

-Govert 

Sep 5, 2011 at 6:47 AM
Ok thanks your for your quick reply and advice. I'll have to skip my epic plans for a function that returns hyperlinks :)

Regards
/Niels

2011/9/4 govert <notifications@codeplex.com>

From: govert

Hi Niels,

The Excel C API does not have any datatype that would allow the magic "HyperLink" to be returned.

If it were a macro that you run from some ribbon button, you could presumably set the formula of the cell to be =HYPERLINK(...).

I suspect the "HYPERLINK" function is one that Excel checks for internally and processes in a special way. Similar to =TODAY(), which reformats the cell to a date format automatically. Our user-defined cannot behave the same way as these built-in functions.

The only workaround would be to fire off a macro that runs after your function has completed, to reformat the cell. I would not recommend going down that road incautiously.

-Govert

Read the full discussion online.

To add a post to this discussion, reply to this email (exceldna@discussions.codeplex.com)

To start a new discussion for this project, email exceldna@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe on CodePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at CodePlex.com