+ Reply to Thread
Results 1 to 3 of 3

How Do I Change this code to not insert object and just do a hyperlink?

  1. #1
    Forum Contributor
    Join Date
    01-09-2016
    Location
    USA,USA
    MS-Off Ver
    2016
    Posts
    1,192

    How Do I Change this code to not insert object and just do a hyperlink?

    Right now this thing puts a button over A1 and I would prefer it elsewhere. How do I change that?


    Sub Contents_Hyperlinks()
    'PURPOSE: Add hyperlinked buttons back to Table of Contents worksheet tab

    Dim sht As Worksheet
    Dim myShape As Shape
    Dim ContentName As String

    'Inputs - Table of Contents Worksheet Name
    ContentName = "Contents"

    'Loop Through Each Worksheet in Workbook
    For Each sht In ActiveWorkbook.Worksheets
    If sht.Name <> ContentName Then

    'Create & Position Shape
    Set myShape = sht.Shapes.AddShape(msoShapeRoundedRectangle, _
    4, 4, 60, 20)

    'Format Shape
    myShape.Fill.ForeColor.RGB = RGB(91, 155, 213) 'Blue
    myShape.Line.Visible = msoFalse
    myShape.TextFrame2.TextRange.Font.Size = 10
    myShape.TextFrame2.TextRange.Text = ContentName
    myShape.TextFrame2.TextRange.Font.Bold = True
    myShape.TextFrame2.TextRange.Font.Fill.ForeColor.RGB = RGB(255, 255, 255) 'White

    'Assign Hyperlink to Shape
    sht.Hyperlinks.Add myShape, "", _
    SubAddress:="'" & ContentName & "'!A1"

    End If
    Next sht

    End Sub

  2. #2
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: How Do I Change this code to not insert object and just do a hyperlink?

    Change the Numbers -

    Please Login or Register  to view this content.
    BTW - Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here

    *Please attend to this right away
    If I've helped you, please consider adding to my reputation - just click on the liitle star at the left.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~(Pride has no aftertaste.)

    You can't do one thing. XLAdept

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~aka Orrin

  3. #3
    Forum Expert Greg M's Avatar
    Join Date
    08-16-2007
    Location
    Dublin. Ireland
    MS-Off Ver
    Office 2016
    Posts
    4,481

    Re: How Do I Change this code to not insert object and just do a hyperlink?

    Hi there,

    The following code will allow you to specify the cell in which the button should appear:

    Please Login or Register  to view this content.

    Hope this helps - please let me know how you get on.

    Regards,

    Greg M

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 0
    Last Post: 06-19-2014, 02:09 PM
  2. VBA code to tell an object to change colour depending on figure in cell
    By Muzza86 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 04-29-2014, 07:29 AM
  3. Macro code to change the ActiveX Control Object Properties
    By jackgan in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-07-2013, 02:31 PM
  4. Change/Modify VB Code to Shift and not insert 2007
    By Excelnoub in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-08-2013, 11:18 AM
  5. Creating code to publish pdf and attach via xl2010 and insert object in body of same email
    By ChrisBrennan in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-26-2013, 09:08 PM
  6. Help with VBA code to change text on pre-made shapr object in 2007
    By lmvk99 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 12-15-2011, 07:00 AM
  7. Insert Hyperlink to WorkBook in which VBA Code resides
    By ron2k_1 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-04-2011, 10:10 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1