![]() |
How can I programmatically add a hyperlink to a cell in the excel ?
"fniles" wrote in message
... In VB6, using an Excel object, how can I programmatically add a hyperlink to a cell in the excel ? Set m_excelObjApp = CreateObject("excel.application") excelObjApp.Workbooks.Add sText = "http://www.myWeb.com" excelObjApp.ActiveWorkbook.ActiveSheet.Cells(1, 1).Value = sText I tried the following codes but got an error: If UCase(Left(sText, 4)) = "HTTP" Then excelObjApp.ActiveWorkbook.ActiveSheet.Hyperlinks. Add Selection, sText, sText End If dim oXL as excel.application dim oWB as excel.workbook dim oWS as excel.worksheet dim oHL as excel.hyperlink set oxl=createobject("excel.application") set owb=oxl.workbooks.add set ows=owb.worksheets(1) if ucase$(left$(stext,4))="HTTP" then set oHL=ows.hyperlinks.add(ows.cells(1,1),sText,,,sTex t) else ows.cells(1,1)=sText end if set ows=nothing set owb=nothing oxl.visible=true set oxl=nothing |
How can I programmatically add a hyperlink to a cell in the excel ?
Thank you very much, that works !
"Bob Butler" wrote in message ... "fniles" wrote in message ... In VB6, using an Excel object, how can I programmatically add a hyperlink to a cell in the excel ? Set m_excelObjApp = CreateObject("excel.application") excelObjApp.Workbooks.Add sText = "http://www.myWeb.com" excelObjApp.ActiveWorkbook.ActiveSheet.Cells(1, 1).Value = sText I tried the following codes but got an error: If UCase(Left(sText, 4)) = "HTTP" Then excelObjApp.ActiveWorkbook.ActiveSheet.Hyperlinks. Add Selection, sText, sText End If dim oXL as excel.application dim oWB as excel.workbook dim oWS as excel.worksheet dim oHL as excel.hyperlink set oxl=createobject("excel.application") set owb=oxl.workbooks.add set ows=owb.worksheets(1) if ucase$(left$(stext,4))="HTTP" then set oHL=ows.hyperlinks.add(ows.cells(1,1),sText,,,sTex t) else ows.cells(1,1)=sText end if set ows=nothing set owb=nothing oxl.visible=true set oxl=nothing |
All times are GMT +1. The time now is 03:32 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com