Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Work-around to Create Hyperlink in VBA

You could plop a button from the Forms toolbar in row 1 of your worksheet.

Then freeze the window (Window|Freeze Panes (in xl2003 menus) so that row 1 is
always visible.

Then assign your macro to the button.

But change the macro slightly.

Option Explicit
Sub MyHyperlinkInNewWindow()
With ActiveCell
If .Hyperlinks.Count 0 Then
ThisWorkbook.FollowHyperlink _
Address:="http://" & .Value, _
NewWindow:=True
End If
End With
End Sub


This will only run if the user selects the cell and clicks on the button--not if
the user clicks on the hyperlink itself.

You could remove the hyperlink and use some other indicator (value starts with
an HTTP://???).

Option Explicit
Sub MyHyperlinkInNewWindow()
With ActiveCell
If UCase(Left(.Value, 7)) = UCase("http://") Then
ThisWorkbook.FollowHyperlink _
Address:=.Value, _
NewWindow:=True
End If
End With
End Sub

(notice that the "http://" was dropped in the second suggestion, while the first
suggestion added it to the hyperlink address.)

PPL wrote:

Thank you to those who replied.
I've found a work-around to the problem of not being able to configure a
hyperlink in Excel to open in a new browser window. Essentially I used an
excel rectangular autoshape drawing object. placed it over the cell that
requires the hyperlink.
Formatted the rectangle w/ white border & no fill (i.e. Transparent)
Removed the hyperlink in the cell & formatted the text in blue w/ underline
Right click the rectangle autoshape Assign Macro

Sub MyHyperlinkInNewWindow
Dim KB_ArticlePath As String
KB_ArticlePath = "http:/anarticle.htm"
ThisWorkbook.FollowHyperlink Address:=KB_ArticlePath, NewWindow:=True
End sub

That's it. It works like a charm.
Not fun for anyone else who wants to change the link because a casual look
at it and you'd never know that it's anything else than ... well .. a
hyperlink!

Phil

"PPL" wrote in message
...
Excel 2002 / 2003.
I'm trying to create a hyperlink in cell A19 such that the result opens in
a new window. I'm using

Range("A19").Select
ActiveSheet.Hyperlinks.Add Anchor:=Selection, Address:="c:\test.htm",
NewWindow:=True, AddHistory:=True

I'm getting Runtime Error 1004: Application defined or Object defined
error

Anyone any idea where am I going wrong ???

TIA






--

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
Need to create an automatic hyperlink [email protected] Excel Discussion (Misc queries) 3 April 1st 10 03:39 PM
Create Hyperlink to URL Filips Benoit[_2_] Excel Programming 4 November 13th 09 07:26 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
Create Hyperlink maperalia Excel Programming 2 April 10th 06 01:15 AM
Create a HYPERLINK with a macro? bobgerman[_3_] Excel Programming 2 December 22nd 03 06:41 PM


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

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

About Us

"It's about Microsoft Excel"