PC Review


Reply
Thread Tools Rate Thread

Delete hyperlink from textbox

 
 
Jarle
Guest
Posts: n/a
 
      5th Mar 2008
I have a hyperlink in a textbox. How can I delete this hyperlink with vba code.

I have tried

Worksheets(1).Shapes("txtbox1").Hyperlinks.Delete

and similar code, but this doesn't work. Can anyone help?

Thank you


rgds
Jarle


 
Reply With Quote
 
 
 
 
Dave Peterson
Guest
Posts: n/a
 
      5th Mar 2008
Is this a hyperlink assigned to the textbox or the value of the text in the
textbox?

I put a textbox from the Drawing toolbar on a worksheet and rightclicked on it
and assigned it a hyperlink.

Then this would delete the hyperlink:

Dim TBox As TextBox
Set TBox = ActiveSheet.TextBoxes("Text Box 1")
'in case there isn't a hyperlink
On Error Resume Next
TBox.ShapeRange.Item(1).Hyperlink.Delete
On Error GoTo 0

Jarle wrote:
>
> I have a hyperlink in a textbox. How can I delete this hyperlink with vba code.
>
> I have tried
>
> Worksheets(1).Shapes("txtbox1").Hyperlinks.Delete
>
> and similar code, but this doesn't work. Can anyone help?
>
> Thank you
>
> rgds
> Jarle


--

Dave Peterson
 
Reply With Quote
 
Jarle
Guest
Posts: n/a
 
      5th Mar 2008
I can't make your code work.

I have assigned the hyperlink with vba code as follows:

sh= Thisworkbook.Worksheets(1)
With sh
.Hyperlinks.Add Anchor:=.Shapes("txtbox1"), _
Address:=destination, _
TextToDisplay:="text"
End With

I am able to clear TextToDisplay with code:

sh.Shapes("txtbox1").TextFrame.Characters.Text = ""

but then the address/hyperlink is still there. It is probably possible to
clear the entire content of textbox (text and hyperlink) in one operation,
but I am not able to figure it out.




I am able to

Dave Peterson skrev:

> Is this a hyperlink assigned to the textbox or the value of the text in the
> textbox?
>
> I put a textbox from the Drawing toolbar on a worksheet and rightclicked on it
> and assigned it a hyperlink.
>
> Then this would delete the hyperlink:
>
> Dim TBox As TextBox
> Set TBox = ActiveSheet.TextBoxes("Text Box 1")
> 'in case there isn't a hyperlink
> On Error Resume Next
> TBox.ShapeRange.Item(1).Hyperlink.Delete
> On Error GoTo 0
>
> Jarle wrote:
> >
> > I have a hyperlink in a textbox. How can I delete this hyperlink with vba code.
> >
> > I have tried
> >
> > Worksheets(1).Shapes("txtbox1").Hyperlinks.Delete
> >
> > and similar code, but this doesn't work. Can anyone help?
> >
> > Thank you
> >
> > rgds
> > Jarle

>
> --
>
> Dave Peterson
>

 
Reply With Quote
 
Dave Peterson
Guest
Posts: n/a
 
      5th Mar 2008
What did you try?

Jarle wrote:
>
> I can't make your code work.
>
> I have assigned the hyperlink with vba code as follows:
>
> sh= Thisworkbook.Worksheets(1)
> With sh
> .Hyperlinks.Add Anchor:=.Shapes("txtbox1"), _
> Address:=destination, _
> TextToDisplay:="text"
> End With
>
> I am able to clear TextToDisplay with code:
>
> sh.Shapes("txtbox1").TextFrame.Characters.Text = ""
>
> but then the address/hyperlink is still there. It is probably possible to
> clear the entire content of textbox (text and hyperlink) in one operation,
> but I am not able to figure it out.
>
> I am able to
>
> Dave Peterson skrev:
>
> > Is this a hyperlink assigned to the textbox or the value of the text in the
> > textbox?
> >
> > I put a textbox from the Drawing toolbar on a worksheet and rightclicked on it
> > and assigned it a hyperlink.
> >
> > Then this would delete the hyperlink:
> >
> > Dim TBox As TextBox
> > Set TBox = ActiveSheet.TextBoxes("Text Box 1")
> > 'in case there isn't a hyperlink
> > On Error Resume Next
> > TBox.ShapeRange.Item(1).Hyperlink.Delete
> > On Error GoTo 0
> >
> > Jarle wrote:
> > >
> > > I have a hyperlink in a textbox. How can I delete this hyperlink with vba code.
> > >
> > > I have tried
> > >
> > > Worksheets(1).Shapes("txtbox1").Hyperlinks.Delete
> > >
> > > and similar code, but this doesn't work. Can anyone help?
> > >
> > > Thank you
> > >
> > > rgds
> > > Jarle

> >
> > --
> >
> > Dave Peterson
> >


--

Dave Peterson
 
Reply With Quote
 
Jarle
Guest
Posts: n/a
 
      5th Mar 2008
I tried:

Set TBox = sh.TextBoxes("txtbox1")
TBox.ShapeRange.Item(1).Hyperlink.Delete

I get :
Run-time error 1004 Application-defined or object-defined error


Dave Peterson skrev:

> What did you try?
>
> Jarle wrote:
> >
> > I can't make your code work.
> >
> > I have assigned the hyperlink with vba code as follows:
> >
> > sh= Thisworkbook.Worksheets(1)
> > With sh
> > .Hyperlinks.Add Anchor:=.Shapes("txtbox1"), _
> > Address:=destination, _
> > TextToDisplay:="text"
> > End With
> >
> > I am able to clear TextToDisplay with code:
> >
> > sh.Shapes("txtbox1").TextFrame.Characters.Text = ""
> >
> > but then the address/hyperlink is still there. It is probably possible to
> > clear the entire content of textbox (text and hyperlink) in one operation,
> > but I am not able to figure it out.
> >
> > I am able to
> >
> > Dave Peterson skrev:
> >
> > > Is this a hyperlink assigned to the textbox or the value of the text in the
> > > textbox?
> > >
> > > I put a textbox from the Drawing toolbar on a worksheet and rightclicked on it
> > > and assigned it a hyperlink.
> > >
> > > Then this would delete the hyperlink:
> > >
> > > Dim TBox As TextBox
> > > Set TBox = ActiveSheet.TextBoxes("Text Box 1")
> > > 'in case there isn't a hyperlink
> > > On Error Resume Next
> > > TBox.ShapeRange.Item(1).Hyperlink.Delete
> > > On Error GoTo 0
> > >
> > > Jarle wrote:
> > > >
> > > > I have a hyperlink in a textbox. How can I delete this hyperlink with vba code.
> > > >
> > > > I have tried
> > > >
> > > > Worksheets(1).Shapes("txtbox1").Hyperlinks.Delete
> > > >
> > > > and similar code, but this doesn't work. Can anyone help?
> > > >
> > > > Thank you
> > > >
> > > > rgds
> > > > Jarle
> > >
> > > --
> > >
> > > Dave Peterson
> > >

>
> --
>
> Dave Peterson
>

 
Reply With Quote
 
Dave Peterson
Guest
Posts: n/a
 
      5th Mar 2008
On which line?

And you deleted the "on error" lines that would have stopped the error from
appearing if there was no hyperlink associated with the textbox.

Jarle wrote:
>
> I tried:
>
> Set TBox = sh.TextBoxes("txtbox1")
> TBox.ShapeRange.Item(1).Hyperlink.Delete
>
> I get :
> Run-time error 1004 Application-defined or object-defined error
>
> Dave Peterson skrev:
>
> > What did you try?
> >
> > Jarle wrote:
> > >
> > > I can't make your code work.
> > >
> > > I have assigned the hyperlink with vba code as follows:
> > >
> > > sh= Thisworkbook.Worksheets(1)
> > > With sh
> > > .Hyperlinks.Add Anchor:=.Shapes("txtbox1"), _
> > > Address:=destination, _
> > > TextToDisplay:="text"
> > > End With
> > >
> > > I am able to clear TextToDisplay with code:
> > >
> > > sh.Shapes("txtbox1").TextFrame.Characters.Text = ""
> > >
> > > but then the address/hyperlink is still there. It is probably possible to
> > > clear the entire content of textbox (text and hyperlink) in one operation,
> > > but I am not able to figure it out.
> > >
> > > I am able to
> > >
> > > Dave Peterson skrev:
> > >
> > > > Is this a hyperlink assigned to the textbox or the value of the text in the
> > > > textbox?
> > > >
> > > > I put a textbox from the Drawing toolbar on a worksheet and rightclicked on it
> > > > and assigned it a hyperlink.
> > > >
> > > > Then this would delete the hyperlink:
> > > >
> > > > Dim TBox As TextBox
> > > > Set TBox = ActiveSheet.TextBoxes("Text Box 1")
> > > > 'in case there isn't a hyperlink
> > > > On Error Resume Next
> > > > TBox.ShapeRange.Item(1).Hyperlink.Delete
> > > > On Error GoTo 0
> > > >
> > > > Jarle wrote:
> > > > >
> > > > > I have a hyperlink in a textbox. How can I delete this hyperlink with vba code.
> > > > >
> > > > > I have tried
> > > > >
> > > > > Worksheets(1).Shapes("txtbox1").Hyperlinks.Delete
> > > > >
> > > > > and similar code, but this doesn't work. Can anyone help?
> > > > >
> > > > > Thank you
> > > > >
> > > > > rgds
> > > > > Jarle
> > > >
> > > > --
> > > >
> > > > Dave Peterson
> > > >

> >
> > --
> >
> > Dave Peterson
> >


--

Dave Peterson
 
Reply With Quote
 
Jarle
Guest
Posts: n/a
 
      5th Mar 2008
Thank you for helping and "pushing" me on this one.
I made your code work perfectly. The OnError did the trick.
I have several textboxes and was convinced there were a hyperlink in each.
It wasn't!

THANKS!

Dave Peterson skrev:

> On which line?
>
> And you deleted the "on error" lines that would have stopped the error from
> appearing if there was no hyperlink associated with the textbox.
>
> Jarle wrote:
> >
> > I tried:
> >
> > Set TBox = sh.TextBoxes("txtbox1")
> > TBox.ShapeRange.Item(1).Hyperlink.Delete
> >
> > I get :
> > Run-time error 1004 Application-defined or object-defined error
> >
> > Dave Peterson skrev:
> >
> > > What did you try?
> > >
> > > Jarle wrote:
> > > >
> > > > I can't make your code work.
> > > >
> > > > I have assigned the hyperlink with vba code as follows:
> > > >
> > > > sh= Thisworkbook.Worksheets(1)
> > > > With sh
> > > > .Hyperlinks.Add Anchor:=.Shapes("txtbox1"), _
> > > > Address:=destination, _
> > > > TextToDisplay:="text"
> > > > End With
> > > >
> > > > I am able to clear TextToDisplay with code:
> > > >
> > > > sh.Shapes("txtbox1").TextFrame.Characters.Text = ""
> > > >
> > > > but then the address/hyperlink is still there. It is probably possible to
> > > > clear the entire content of textbox (text and hyperlink) in one operation,
> > > > but I am not able to figure it out.
> > > >
> > > > I am able to
> > > >
> > > > Dave Peterson skrev:
> > > >
> > > > > Is this a hyperlink assigned to the textbox or the value of the text in the
> > > > > textbox?
> > > > >
> > > > > I put a textbox from the Drawing toolbar on a worksheet and rightclicked on it
> > > > > and assigned it a hyperlink.
> > > > >
> > > > > Then this would delete the hyperlink:
> > > > >
> > > > > Dim TBox As TextBox
> > > > > Set TBox = ActiveSheet.TextBoxes("Text Box 1")
> > > > > 'in case there isn't a hyperlink
> > > > > On Error Resume Next
> > > > > TBox.ShapeRange.Item(1).Hyperlink.Delete
> > > > > On Error GoTo 0
> > > > >
> > > > > Jarle wrote:
> > > > > >
> > > > > > I have a hyperlink in a textbox. How can I delete this hyperlink with vba code.
> > > > > >
> > > > > > I have tried
> > > > > >
> > > > > > Worksheets(1).Shapes("txtbox1").Hyperlinks.Delete
> > > > > >
> > > > > > and similar code, but this doesn't work. Can anyone help?
> > > > > >
> > > > > > Thank you
> > > > > >
> > > > > > rgds
> > > > > > Jarle
> > > > >
> > > > > --
> > > > >
> > > > > Dave Peterson
> > > > >
> > >
> > > --
> > >
> > > Dave Peterson
> > >

>
> --
>
> Dave Peterson
>

 
Reply With Quote
 
Dave Peterson
Guest
Posts: n/a
 
      5th Mar 2008
Glad you got it working.

Jarle wrote:
>
> Thank you for helping and "pushing" me on this one.
> I made your code work perfectly. The OnError did the trick.
> I have several textboxes and was convinced there were a hyperlink in each.
> It wasn't!
>
> THANKS!
>
> Dave Peterson skrev:
>
> > On which line?
> >
> > And you deleted the "on error" lines that would have stopped the error from
> > appearing if there was no hyperlink associated with the textbox.
> >
> > Jarle wrote:
> > >
> > > I tried:
> > >
> > > Set TBox = sh.TextBoxes("txtbox1")
> > > TBox.ShapeRange.Item(1).Hyperlink.Delete
> > >
> > > I get :
> > > Run-time error 1004 Application-defined or object-defined error
> > >
> > > Dave Peterson skrev:
> > >
> > > > What did you try?
> > > >
> > > > Jarle wrote:
> > > > >
> > > > > I can't make your code work.
> > > > >
> > > > > I have assigned the hyperlink with vba code as follows:
> > > > >
> > > > > sh= Thisworkbook.Worksheets(1)
> > > > > With sh
> > > > > .Hyperlinks.Add Anchor:=.Shapes("txtbox1"), _
> > > > > Address:=destination, _
> > > > > TextToDisplay:="text"
> > > > > End With
> > > > >
> > > > > I am able to clear TextToDisplay with code:
> > > > >
> > > > > sh.Shapes("txtbox1").TextFrame.Characters.Text = ""
> > > > >
> > > > > but then the address/hyperlink is still there. It is probably possible to
> > > > > clear the entire content of textbox (text and hyperlink) in one operation,
> > > > > but I am not able to figure it out.
> > > > >
> > > > > I am able to
> > > > >
> > > > > Dave Peterson skrev:
> > > > >
> > > > > > Is this a hyperlink assigned to the textbox or the value of the text in the
> > > > > > textbox?
> > > > > >
> > > > > > I put a textbox from the Drawing toolbar on a worksheet and rightclicked on it
> > > > > > and assigned it a hyperlink.
> > > > > >
> > > > > > Then this would delete the hyperlink:
> > > > > >
> > > > > > Dim TBox As TextBox
> > > > > > Set TBox = ActiveSheet.TextBoxes("Text Box 1")
> > > > > > 'in case there isn't a hyperlink
> > > > > > On Error Resume Next
> > > > > > TBox.ShapeRange.Item(1).Hyperlink.Delete
> > > > > > On Error GoTo 0
> > > > > >
> > > > > > Jarle wrote:
> > > > > > >
> > > > > > > I have a hyperlink in a textbox. How can I delete this hyperlink with vba code.
> > > > > > >
> > > > > > > I have tried
> > > > > > >
> > > > > > > Worksheets(1).Shapes("txtbox1").Hyperlinks.Delete
> > > > > > >
> > > > > > > and similar code, but this doesn't work. Can anyone help?
> > > > > > >
> > > > > > > Thank you
> > > > > > >
> > > > > > > rgds
> > > > > > > Jarle
> > > > > >
> > > > > > --
> > > > > >
> > > > > > Dave Peterson
> > > > > >
> > > >
> > > > --
> > > >
> > > > Dave Peterson
> > > >

> >
> > --
> >
> > Dave Peterson
> >


--

Dave Peterson
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Hyperlink in TextBox KWC Microsoft Access Forms 0 14th Jan 2008 08:48 PM
Hyperlink in a textbox =?Utf-8?B?TGVuUA==?= Microsoft Access Forms 0 16th Dec 2005 09:03 PM
hyperlink in textbox =?Utf-8?B?Qg==?= Microsoft Access VBA Modules 1 14th Jun 2005 10:59 AM
hyperlink in textbox =?Utf-8?B?Qg==?= Microsoft Access 0 14th Jun 2005 08:43 AM
Hyperlink in a TextBox - Possible? theintrepidfox@hotmail.com Microsoft ASP .NET 2 4th Mar 2005 11:13 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:38 PM.