Adding Hyperlink in Excel Soreadsheet

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
 
S

strive4peace

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 :)
*
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top