Wrox Programmer Forums
|
ASP.NET 2.0 Professional If you are an experienced ASP.NET programmer, this is the forum for your 2.0 questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 11th, 2010, 07:21 AM
Authorized User
 
Join Date: Apr 2008
Posts: 85
Thanks: 10
Thanked 0 Times in 0 Posts
Default Problem with Hyperlink

Hi All,
Below is the code for adding hyperlink in Excelsheet but its giving me error.

Code:
Imports Excel = Microsoft.Office.Interop.Excel 
 
Dim xlWorkBook As Excel.Workbook
Dim xlWorkSheet As Excel.Worksheet
xlWorkBook = New Excel.Application().Workbooks.Open("C:\Practice.xls")
xlWorkSheet = xlWorkBook.ActiveSheet
xlWorkSheet.Cells(1, 1) = xlWorkSheet.Hyperlinks.Add(Anchor:="Selection", Address:="http://www.MySite.com", TextToDisplay:="Clickhere")
 xlWorkBook.Save()
 xlWorkBook.Close()
Is this the correct way to add hyperlink in Excel if not Can you please tell me how can i do that.
below part of the above code i have generated using 'macro' in excel.
Anchor:="Selection", Address:="http://www.MySite.com", TextToDisplay:="Clickhere"

Thanks
Nelly

Last edited by nelly78; January 11th, 2010 at 10:41 AM..
 
Old January 11th, 2010, 08:30 AM
Friend of Wrox
 
Join Date: May 2004
Posts: 642
Thanks: 0
Thanked 43 Times in 42 Posts
Default

Please check the following code:
Code:
Dim xlWorkBook As Excel.Workbook
Dim xlWorkSheet As Excel.Worksheet
xlWorkBook = New Excel.Application().Workbooks.Open("C:\Blubaker\Practice.xls")
xlWorkSheet = xlWorkBook.ActiveSheet
Dim link As Excel.Hyperlink = CType(xlWorkSheet.Hyperlinks.Add(xlWorkSheet.Range("A1"), "http://www.MySite.com", ScreenTip:="MyWebsite", TextToDisplay:="Clickhere"), Excel.Hyperlink)
xlWorkBook.Save()
xlWorkBook.Close()
__________________
Om Prakash Pant
Click the "Thanks" button if this post helped you.
The Following User Says Thank You to om_prakash For This Useful Post:
nelly78 (January 11th, 2010)
 
Old January 11th, 2010, 10:51 AM
Authorized User
 
Join Date: Apr 2008
Posts: 85
Thanks: 10
Thanked 0 Times in 0 Posts
Default

Hi Om Prakash,

Thank you very much. Its working perfectly :-)

Thanks





Similar Threads
Thread Thread Starter Forum Replies Last Post
hyperlink problem hastikeyvan Classic ASP Professional 5 January 22nd, 2007 07:03 PM
HyperLink Problem monika.vasvani ASP.NET 1.0 and 1.1 Professional 2 September 30th, 2006 05:17 AM
Hyperlink Problem Lalit Pradhan ASP.NET 2.0 Professional 2 June 14th, 2006 09:36 AM
hyperlink problem Abhinav_jain_mca General .NET 3 August 27th, 2004 07:54 AM
hyperlink problem Abhinav_jain_mca SQL Server 2000 1 August 25th, 2004 01:43 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.