excel vba add hyperlink to shape in group -


i have absolutely no idea why cannot add hyperlink shape if trigged in-cell function. when run manually immediate window, working well. don't have troubles doing manually.

i have no idea how write error handling in vba

this sample code.

function testcase(xllabelname string) dim sht worksheet     each sht in activeworkbook.sheets         if shapeexist(sht, xllabelname)             sht.hyperlinks.add anchor:=sht.shapes(xllabelname), address:="", subaddress:="a1"              testcase = "bingo"         end if     next sht end function 

from immediate window bingo answer , in cell #arg! error , line not executed. tried ungroup shapes first using

dim gshp shape dim shrng shaperange dim tmp string set gshp = sht.shapes(getparentshape(xllabelname)) tmp = gshp.name set shrng = gshp.ungroup sht.hyperlinks.add anchor:=sht.shapes(xllabelname), address:="", subaddress:="a1" shrng.regroup shrng.name = tmp 

but failed. , still immediate window gives me correct answer (bingo) other operations done needed (painting), 1 fails. if remove problematic line got correct response in cell. shape i'm trying deal msofreeform
function check if shape exist loop through shapes in sheet , compare names (lame working)

thanks in advance.

if assign macro shape run following sub when clicked:

sub hyperlinkshape     thisworkbook.followhyperlink ("c:\temp\test.xlsx") end sub 

if you're looking hyperlink within workbook, such changing sheets, can write

sub hyperlinkshape     sheets("desiredsheet").select end sub 

this way hyperlink not attached shape, sub. clicking shape can launch sub.

for error handling, suggest read answers thread posted few months back: vba excel simple error handling


Comments

  1. @admin

    We provide quality dental care, conveniently in your neighborhood, and cater to your schedule. Because your comfort is important to us, we offer many of the modern amenities you’ve come to expect in a dental office.

    Regards,
    Dentist In Northampton, MA

    ReplyDelete
  2. @admin

    We provide quality dental care, conveniently in your neighborhood, and cater to your schedule. Because your comfort is important to us, we offer many of the modern amenities you’ve come to expect in a dental office.

    Regards,
    Dentist In Northampton, MA

    ReplyDelete
  3. @admin

    Our dental team is committed to excellent oral health for our patients. We offer comprehensive dental care and brilliant cosmetic dentistry to EAST HARTFORD and the surrounding areas.

    Regards,
    Dentist In East Hartford, CT

    ReplyDelete

Post a Comment

Popular posts from this blog

html - Firefox flex bug applied to buttons? -

html - Missing border-right in select on Firefox -

c# - two queries in same method -