Adding Hyperlink in Excel Soreadsheet

  • Thread starter Thread starter raviyah
  • Start date Start date
R

raviyah

How do I add a hyperlink to a cell in Excel from Access VBA. my code is:

xlApp.Cells(vRow, vCol).Select
xlApp.ActiveSheet.Hyperlinks.Add Anchor:=Selection, Address:= _
strHyperLink, TextToDisplay:=strDisplay

I am getting an automation error
 
Hi raviyah,

Selection needs to be prefaced with where it comes from ...

if you did it this way, you would use
Anchor:=xlApp.ActiveSheet.Selection

.... BUT -- why select the cell first, just do this:

Anchor:=xlApp.ActiveSheet.Cells(vRow, vCol)

it is always better to avoid selecting things; there are only a few
commands where you must select something for them to work -- like
freezing panes. You don't even need ActiveSheet -- you could use
Sheets(#) or Sheets("sheetname")



Warm Regards,
Crystal
remote programming and training

Video Tutorials on YouTube!
http://www.youtube.com/user/LearnAccessByCrystal

Access Basics
8-part free tutorial that covers essentials in Access
http://www.AccessMVP.com/strive4peace

*
(: have an awesome day :)
*
 
Back
Top