Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 39
Default ThisWorkbook.FollowHyperlink to Location in Workbook

I can get the following to work in a VBA sub:

ThisWorkbook.FollowHyperlink Address:="http://example.microsoft.com"

but get an error when I try to specify a location in the workbook with:

ThisWorkbook.FollowHyperlink Address:="", SubAddress:="Sheet1!A3"

It seemed that would be the proper format for the address in the open
workbook, but I'm picking up an error - "Run time error 5 - Invalid
procedure call or argument"

What am I missing or doing wrong here? I really need to do this
programatically and not have to define a "fixed" hyperlink on the worksheet
(or anywhere else).

Thanks in advance for any help you can give!

James


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 770
Default ThisWorkbook.FollowHyperlink to Location in Workbook

James,

Running the macro recorder, I get this, which adds the Anchor parameter to
what you've got. Does that help?

ActiveSheet.Hyperlinks.Add Anchor:=Selection, Address:="", SubAddress:= _
"Sheet2!A1", TextToDisplay:="Sheet2!A1"

Doug

"James Cox" wrote in message
...
I can get the following to work in a VBA sub:

ThisWorkbook.FollowHyperlink Address:="http://example.microsoft.com"

but get an error when I try to specify a location in the workbook with:

ThisWorkbook.FollowHyperlink Address:="", SubAddress:="Sheet1!A3"

It seemed that would be the proper format for the address in the open
workbook, but I'm picking up an error - "Run time error 5 - Invalid
procedure call or argument"

What am I missing or doing wrong here? I really need to do this
programatically and not have to define a "fixed" hyperlink on the

worksheet
(or anywhere else).

Thanks in advance for any help you can give!

James




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 39
Default ThisWorkbook.FollowHyperlink to Location in Workbook

Doug -

Well, that adds a hyperlink to the workbook at the location of the current
cell - which I need to avoid because it could overwrite whatever was in the
current cell when the macro runs.

Also, it doesn't go to the hyperlink target - just creates the hyperlink and
stays there.

Thanks for the help, but that's not the functionality needed....

James



"Doug Glancy" wrote in message
...
James,

Running the macro recorder, I get this, which adds the Anchor parameter to
what you've got. Does that help?

ActiveSheet.Hyperlinks.Add Anchor:=Selection, Address:="", SubAddress:= _
"Sheet2!A1", TextToDisplay:="Sheet2!A1"

Doug

"James Cox" wrote in message
...
I can get the following to work in a VBA sub:

ThisWorkbook.FollowHyperlink Address:="http://example.microsoft.com"

but get an error when I try to specify a location in the workbook with:

ThisWorkbook.FollowHyperlink Address:="", SubAddress:="Sheet1!A3"

It seemed that would be the proper format for the address in the open
workbook, but I'm picking up an error - "Run time error 5 - Invalid
procedure call or argument"

What am I missing or doing wrong here? I really need to do this
programatically and not have to define a "fixed" hyperlink on the

worksheet
(or anywhere else).

Thanks in advance for any help you can give!

James






  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default ThisWorkbook.FollowHyperlink to Location in Workbook

Sub AA()
ActiveWorkbook.FollowHyperlink _
Address:="C:\Data\Add_Button.xls", _
SubAddress:="Sheet2!B3"
End Sub

worked fine for me.

--
Regards,
Tom Ogilvy

"James Cox" wrote in message
...
Doug -

Well, that adds a hyperlink to the workbook at the location of the current
cell - which I need to avoid because it could overwrite whatever was in

the
current cell when the macro runs.

Also, it doesn't go to the hyperlink target - just creates the hyperlink

and
stays there.

Thanks for the help, but that's not the functionality needed....

James



"Doug Glancy" wrote in message
...
James,

Running the macro recorder, I get this, which adds the Anchor parameter

to
what you've got. Does that help?

ActiveSheet.Hyperlinks.Add Anchor:=Selection, Address:="", SubAddress:=

_
"Sheet2!A1", TextToDisplay:="Sheet2!A1"

Doug

"James Cox" wrote in message
...
I can get the following to work in a VBA sub:

ThisWorkbook.FollowHyperlink

Address:="http://example.microsoft.com"

but get an error when I try to specify a location in the workbook

with:

ThisWorkbook.FollowHyperlink Address:="", SubAddress:="Sheet1!A3"

It seemed that would be the proper format for the address in the open
workbook, but I'm picking up an error - "Run time error 5 - Invalid
procedure call or argument"

What am I missing or doing wrong here? I really need to do this
programatically and not have to define a "fixed" hyperlink on the

worksheet
(or anywhere else).

Thanks in advance for any help you can give!

James








  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 595
Default ThisWorkbook.FollowHyperlink to Location in Workbook

James

ThisWorkbook.FollowHyperlink "#Sheet1!A3"

Not very intuitive, but that's what works.

--
Dick Kusleika
Excel MVP
Daily Dose of Excel
www.dicks-blog.com


James Cox wrote:
I can get the following to work in a VBA sub:

ThisWorkbook.FollowHyperlink
Address:="http://example.microsoft.com"

but get an error when I try to specify a location in the workbook
with:

ThisWorkbook.FollowHyperlink Address:="", SubAddress:="Sheet1!A3"

It seemed that would be the proper format for the address in the open
workbook, but I'm picking up an error - "Run time error 5 - Invalid
procedure call or argument"

What am I missing or doing wrong here? I really need to do this
programatically and not have to define a "fixed" hyperlink on the
worksheet (or anywhere else).

Thanks in advance for any help you can give!

James





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default ThisWorkbook.FollowHyperlink to Location in Workbook

Sorry - didn't realize you were moving in the same workbook.

I am sure Dick's example works, but why use a hyperlink. Why not use

Sub AA()
Application.GoTo Reference:=Worksheets("Sheet2").Range("B3"), _
Scroll:=True
End Sub


--
Regards,
Tom Ogilvy


"Tom Ogilvy" wrote in message
...
Sub AA()
ActiveWorkbook.FollowHyperlink _
Address:="C:\Data\Add_Button.xls", _
SubAddress:="Sheet2!B3"
End Sub

worked fine for me.

--
Regards,
Tom Ogilvy

"James Cox" wrote in message
...
Doug -

Well, that adds a hyperlink to the workbook at the location of the

current
cell - which I need to avoid because it could overwrite whatever was in

the
current cell when the macro runs.

Also, it doesn't go to the hyperlink target - just creates the hyperlink

and
stays there.

Thanks for the help, but that's not the functionality needed....

James



"Doug Glancy" wrote in message
...
James,

Running the macro recorder, I get this, which adds the Anchor

parameter
to
what you've got. Does that help?

ActiveSheet.Hyperlinks.Add Anchor:=Selection, Address:="",

SubAddress:=
_
"Sheet2!A1", TextToDisplay:="Sheet2!A1"

Doug

"James Cox" wrote in message
...
I can get the following to work in a VBA sub:

ThisWorkbook.FollowHyperlink

Address:="http://example.microsoft.com"

but get an error when I try to specify a location in the workbook

with:

ThisWorkbook.FollowHyperlink Address:="",

SubAddress:="Sheet1!A3"

It seemed that would be the proper format for the address in the

open
workbook, but I'm picking up an error - "Run time error 5 - Invalid
procedure call or argument"

What am I missing or doing wrong here? I really need to do this
programatically and not have to define a "fixed" hyperlink on the
worksheet
(or anywhere else).

Thanks in advance for any help you can give!

James










  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 770
Default ThisWorkbook.FollowHyperlink to Location in Workbook

I obviously missed the boat on this one - and I'm curious, is this
different, or better than, Application.Goto?

Thanks,

Doug

"Dick Kusleika" wrote in message
...
James

ThisWorkbook.FollowHyperlink "#Sheet1!A3"

Not very intuitive, but that's what works.

--
Dick Kusleika
Excel MVP
Daily Dose of Excel
www.dicks-blog.com


James Cox wrote:
I can get the following to work in a VBA sub:

ThisWorkbook.FollowHyperlink
Address:="http://example.microsoft.com"

but get an error when I try to specify a location in the workbook
with:

ThisWorkbook.FollowHyperlink Address:="", SubAddress:="Sheet1!A3"

It seemed that would be the proper format for the address in the open
workbook, but I'm picking up an error - "Run time error 5 - Invalid
procedure call or argument"

What am I missing or doing wrong here? I really need to do this
programatically and not have to define a "fixed" hyperlink on the
worksheet (or anywhere else).

Thanks in advance for any help you can give!

James





  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 595
Default ThisWorkbook.FollowHyperlink to Location in Workbook

Different and worse, I would say. I think you get more options with Goto
that would make that a better choice. I can think of one situation where
FollowHyperlink would be better: If you are building the string dynamically
and sometimes it points inside the workbook, sometimes to another workbook,
and sometimes to another program. In that case you could use one method to
do it all and just build the appropriate string. Beyond that, I'd go with
Goto.

--
Dick Kusleika
Excel MVP
Daily Dose of Excel
www.dicks-blog.com

Doug Glancy wrote:
I obviously missed the boat on this one - and I'm curious, is this
different, or better than, Application.Goto?

Thanks,

Doug

"Dick Kusleika" wrote in message
...
James

ThisWorkbook.FollowHyperlink "#Sheet1!A3"

Not very intuitive, but that's what works.

--
Dick Kusleika
Excel MVP
Daily Dose of Excel
www.dicks-blog.com


James Cox wrote:
I can get the following to work in a VBA sub:

ThisWorkbook.FollowHyperlink
Address:="http://example.microsoft.com"

but get an error when I try to specify a location in the workbook
with:

ThisWorkbook.FollowHyperlink Address:="", SubAddress:="Sheet1!A3"

It seemed that would be the proper format for the address in the
open workbook, but I'm picking up an error - "Run time error 5 -
Invalid procedure call or argument"

What am I missing or doing wrong here? I really need to do this
programatically and not have to define a "fixed" hyperlink on the
worksheet (or anywhere else).

Thanks in advance for any help you can give!

James



  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 39
Default ThisWorkbook.FollowHyperlink to Location in Workbook

Thanks for all the high-powered help, folks!

The comments about the use of Application.GoTo make sense, but I got into
the hyperlink mindset because this question underlies a need to jump to (and
back from) a shape on a worksheet. The use of hyperlinks was providing an
easy way to get back to the original anchor location - something that GoTo
didn't seem to provide.

More globally, this was a way to do hyperlink documentation of the flowchart
of a program, with detailed documentation in shapes on a differerent
worksheet in the workbook. However, the comment from Dick about sometimes
pointing to inside the workbook and sometimes to an external workbook has
gotten me thinking about the possibility of keeping a centralized version of
the documentation and letting the customized versions of the workbook
hyperlink back to the detailed documentation in a master workbook. This has
the potential of cutting down on the labor to update all the copies of the
workbook in use...

Again, thanks for the help! For the time being, I'll be #'ing around in the
local workbook with an eye out for the advantages of dynamic hyperlink
creation - unless someone has an insight into a slick implementation of
"GoTo / GoBack" functionality that's based on Application.GoTo.

James


"James Cox" wrote in message
...
I can get the following to work in a VBA sub:

ThisWorkbook.FollowHyperlink Address:="http://example.microsoft.com"

but get an error when I try to specify a location in the workbook with:

ThisWorkbook.FollowHyperlink Address:="", SubAddress:="Sheet1!A3"

It seemed that would be the proper format for the address in the open
workbook, but I'm picking up an error - "Run time error 5 - Invalid
procedure call or argument"

What am I missing or doing wrong here? I really need to do this
programatically and not have to define a "fixed" hyperlink on the

worksheet
(or anywhere else).

Thanks in advance for any help you can give!

James




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 to workbook location jaclh2o Excel Worksheet Functions 0 September 23rd 08 08:28 PM
FollowHyperlink to OLEObject Tony Excel Programming 0 January 5th 05 10:15 PM
FollowHyperlink Mike Archer[_3_] Excel Programming 0 December 19th 03 12:26 PM
followhyperlink Mike Archer[_2_] Excel Programming 0 December 18th 03 03:19 PM
followhyperlink failure Ron Dahl Excel Programming 2 November 4th 03 02:51 PM


All times are GMT +1. The time now is 09:36 AM.

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"