Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default How do I add a hyperlink to a particular cell to a textbox using vba?

Good afternoon!

I have a macro which creates text boxes in excel, based on values in a
hidden worksheet. One of thos values is a location within the
workbook, ie "Sheet1!A2". When creating the textbox in vba, I would
like the text box (or the text within the box) to be linked to that
cell. I have looked everywhere and cannot find anything on how to do
this.

Here is the code which creates the textbox:

dim dealtextbox as shape

Set DealTextbox =
Sheets(1).Shapes.AddTextbox(Orientation:=msoTextOr ientationHorizontal,
_
Left:=350, Top:=lengthPrevBox + 10, Width:=600, Height:=10)

With DealTextbox
.TextFrame.AutoSize = True
If .Width 300 Then
y = .Width * .Height
.Width = 300
.Height = (y / 200)
End If
.TextFrame.Characters(1, 11).Font.Bold = True
end with

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default How do I add a hyperlink to a particular cell to a textbox usingvba?

I added the textbox going through the Textboxes collection--not through the
shapes collection.

Option Explicit
Sub testme()

Dim DealTextBox As TextBox
Dim y As Long

Set DealTextBox = ActiveSheet.TextBoxes.Add _
(Top:=0, Left:=0, Width:=300, Height:=200)

With DealTextBox
.AutoSize = True
If .Width 300 Then
y = .Width * .Height
.Width = 300
.Height = (y / 200)
End If
.Formula = "=Sheet1!a1"
.Characters(1, 11).Font.Bold = True
End With
End Sub

But if you point to a cell, I don't think bolding of characters will work the
way you want.

wrote:

Good afternoon!

I have a macro which creates text boxes in excel, based on values in a
hidden worksheet. One of thos values is a location within the
workbook, ie "Sheet1!A2". When creating the textbox in vba, I would
like the text box (or the text within the box) to be linked to that
cell. I have looked everywhere and cannot find anything on how to do
this.

Here is the code which creates the textbox:

dim dealtextbox as shape

Set DealTextbox =
Sheets(1).Shapes.AddTextbox(Orientation:=msoTextOr ientationHorizontal,
_
Left:=350, Top:=lengthPrevBox + 10, Width:=600, Height:=10)

With DealTextbox
.TextFrame.AutoSize = True
If .Width 300 Then
y = .Width * .Height
.Width = 300
.Height = (y / 200)
End If
.TextFrame.Characters(1, 11).Font.Bold = True
end with


--

Dave Peterson
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
hyperlink cell to word in textbox dgold82 Excel Discussion (Misc queries) 0 June 28th 09 07:08 AM
How do I create a hyperlink to a cell with the hyperlink function S. Bevins Excel Worksheet Functions 2 July 20th 06 08:06 PM
Hyperlink within Textbox(UserForm) Soniya[_4_] Excel Programming 1 December 14th 05 05:14 PM
Textbox Hyperlink opens VB Editor at Specific Module Neily[_3_] Excel Programming 0 October 26th 05 12:04 PM
Excel VBA to email a hyperlink from a textbox doodlebug Excel Programming 2 August 4th 05 11:07 AM


All times are GMT +1. The time now is 08:53 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"