Link to home
Start Free TrialLog in
Avatar of jribble
jribble

asked on

Creating a HyperLink from a cell to a worksheet using C#

I have written a C# application using VS2005.NET to generate an Excel spreadsheet.  My first worksheet contains an index to the other worksheets and I want to autogenerate a HyperLink using my C# application from cells in the first worksheet to the other worksheets.

I have seen many examples of linking to a web page and have done this using something like this:

worksheet.Hyperlinks.Add(hyperLinkRange, "HTTP:\\www.google.com",Type.Missing, Type.Missing, "Hyperlink Test");

The problem I have is I'm not sure how to reference a worksheet in the same Excel file.



ASKER CERTIFIED SOLUTION
Avatar of katlin924
katlin924
Flag of Philippines image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jribble
jribble

ASKER

katlin924,

Your possible solution was helpful.  As it turns out I was missing the apostrophes.  Here is the line of code that worked for me:

indexWorksheet.Hyperlinks.Add(smsIngredientRange, "", "'" + chartWorksheet.Name + "'!A1", Type.Missing, smsIngredientCode);

Thanks,

Joe
Glad it worked. Happy to be of help. :)