Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 194
Default In Excel VBA, open .txt with Word?

I have a macro in my workbook that returns a(ll) hyperlink(s) to the
requested Word document(s) using the ActiveCell.Text as the document name.
It works great - except now I have to apply it to a bunch of .txt files.
These open in Notepad - I need Word for functionality when the document is
open.

Is there a way I can set a "When Clicked" event so that, when one of these
hyperlinks is clicked on, a macro will launch Word and open the selected
file? I'd probably have to remove the hyperlink formatting, I think, so my
returned file name could be used as the doc name.

Am I asking too much? Is there an easier way?

Ed


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default In Excel VBA, open .txt with Word?

You could set the hyperlink to the cell with the hyperlink. Then use the
followHyperlink event to do what you want.

--
Regards,
Tom Ogilvy

"Ed" wrote in message
...
I have a macro in my workbook that returns a(ll) hyperlink(s) to the
requested Word document(s) using the ActiveCell.Text as the document name.
It works great - except now I have to apply it to a bunch of .txt files.
These open in Notepad - I need Word for functionality when the document is
open.

Is there a way I can set a "When Clicked" event so that, when one of these
hyperlinks is clicked on, a macro will launch Word and open the selected
file? I'd probably have to remove the hyperlink formatting, I think, so

my
returned file name could be used as the doc name.

Am I asking too much? Is there an easier way?

Ed




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 194
Default In Excel VBA, open .txt with Word?

Please excuse my slowness, Tom, but I'm not following this too well. The
Help files show the FollowHyperlink event as a complete and separate macro
Sub. So I take a "helper" cell, and make it point to the hyperlink, and set
an On_Click in that cell that calls the FollowHyperlink sub? Sorry if I've
managed to mangle something that should be easy.

Ed

"Tom Ogilvy" wrote in message
...
You could set the hyperlink to the cell with the hyperlink. Then use the
followHyperlink event to do what you want.

--
Regards,
Tom Ogilvy

"Ed" wrote in message
...
I have a macro in my workbook that returns a(ll) hyperlink(s) to the
requested Word document(s) using the ActiveCell.Text as the document

name.
It works great - except now I have to apply it to a bunch of .txt files.
These open in Notepad - I need Word for functionality when the document

is
open.

Is there a way I can set a "When Clicked" event so that, when one of

these
hyperlinks is clicked on, a macro will launch Word and open the selected
file? I'd probably have to remove the hyperlink formatting, I think, so

my
returned file name could be used as the doc name.

Am I asking too much? Is there an easier way?

Ed






  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default In Excel VBA, open .txt with Word?

FollowHyperlink is an event that fires when a hyperlink is clicked on that
page

From help:
Occurs when you click any hyperlink on a worksheet. For application- and
workbook-level events, see the SheetFollowHyperlink event.

Syntax

Private Sub Worksheet_FollowHyperlink(ByVal Target As Hyperlink)

Target Required Hyperlink. A Hyperlink object that represents the
destination of the hyperlink.

--------------------------



I put in a hyperlink and had it point to the cell containing the hyperlink.



I put in this event for the sheet

Private Sub Worksheet_FollowHyperlink(ByVal Target As Hyperlink)
MsgBox Target.SubAddress
End Sub


It displayed Sheet1!E6 which is the address of the cell with the
hyperlink. I could use that information in a case statement to open a
specific text file in word using automation.

Beyond triggering the FollowHyperlink event, there was not change in the
worksheet, since the focus stayed on that cell. If the focus was not on that
cell, it moved to that cell.

--

Regards,

Tom Ogilvy



"Ed" wrote in message
...
Please excuse my slowness, Tom, but I'm not following this too well. The
Help files show the FollowHyperlink event as a complete and separate macro
Sub. So I take a "helper" cell, and make it point to the hyperlink, and

set
an On_Click in that cell that calls the FollowHyperlink sub? Sorry if

I've
managed to mangle something that should be easy.

Ed

"Tom Ogilvy" wrote in message
...
You could set the hyperlink to the cell with the hyperlink. Then use

the
followHyperlink event to do what you want.

--
Regards,
Tom Ogilvy

"Ed" wrote in message
...
I have a macro in my workbook that returns a(ll) hyperlink(s) to the
requested Word document(s) using the ActiveCell.Text as the document

name.
It works great - except now I have to apply it to a bunch of .txt

files.
These open in Notepad - I need Word for functionality when the

document
is
open.

Is there a way I can set a "When Clicked" event so that, when one of

these
hyperlinks is clicked on, a macro will launch Word and open the

selected
file? I'd probably have to remove the hyperlink formatting, I think,

so
my
returned file name could be used as the doc name.

Am I asking too much? Is there an easier way?

Ed








  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 194
Default In Excel VBA, open .txt with Word?

Thanks, Tom. I appreciate your assistance and patience. I'll work on this
one and scream if my spreadsheet starts smoking!

Ed

"Tom Ogilvy" wrote in message
...
FollowHyperlink is an event that fires when a hyperlink is clicked on that
page

From help:
Occurs when you click any hyperlink on a worksheet. For application- and
workbook-level events, see the SheetFollowHyperlink event.

Syntax

Private Sub Worksheet_FollowHyperlink(ByVal Target As Hyperlink)

Target Required Hyperlink. A Hyperlink object that represents the
destination of the hyperlink.

--------------------------



I put in a hyperlink and had it point to the cell containing the

hyperlink.



I put in this event for the sheet

Private Sub Worksheet_FollowHyperlink(ByVal Target As Hyperlink)
MsgBox Target.SubAddress
End Sub


It displayed Sheet1!E6 which is the address of the cell with the
hyperlink. I could use that information in a case statement to open a
specific text file in word using automation.

Beyond triggering the FollowHyperlink event, there was not change in the
worksheet, since the focus stayed on that cell. If the focus was not on

that
cell, it moved to that cell.

--

Regards,

Tom Ogilvy



"Ed" wrote in message
...
Please excuse my slowness, Tom, but I'm not following this too well.

The
Help files show the FollowHyperlink event as a complete and separate

macro
Sub. So I take a "helper" cell, and make it point to the hyperlink, and

set
an On_Click in that cell that calls the FollowHyperlink sub? Sorry if

I've
managed to mangle something that should be easy.

Ed

"Tom Ogilvy" wrote in message
...
You could set the hyperlink to the cell with the hyperlink. Then use

the
followHyperlink event to do what you want.

--
Regards,
Tom Ogilvy

"Ed" wrote in message
...
I have a macro in my workbook that returns a(ll) hyperlink(s) to the
requested Word document(s) using the ActiveCell.Text as the document

name.
It works great - except now I have to apply it to a bunch of .txt

files.
These open in Notepad - I need Word for functionality when the

document
is
open.

Is there a way I can set a "When Clicked" event so that, when one of

these
hyperlinks is clicked on, a macro will launch Word and open the

selected
file? I'd probably have to remove the hyperlink formatting, I

think,
so
my
returned file name could be used as the doc name.

Am I asking too much? Is there an easier way?

Ed










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
Excel Hyperlink doesn't open Word doc the same way as Word does duugg Excel Discussion (Misc queries) 2 October 12th 06 03:14 PM
Can't open files in Excel or Word rortiz Excel Discussion (Misc queries) 2 April 19th 06 01:32 AM
How to open a word doc while in Excel Katie Excel Discussion (Misc queries) 5 February 21st 06 07:56 PM
open Word from excel Macro hurst,j Excel Worksheet Functions 0 December 2nd 04 03:27 PM
open a new word document out of excel walt Excel Programming 0 August 11th 03 09:22 PM


All times are GMT +1. The time now is 09:33 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"