Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Word hyperlink in Excel

Status
Not open for further replies.

ranebow

Programmer
Mar 8, 2003
110
US
In Excel, I've done a hyperlink to a TXT file that is downloaded via another software package. Is there any way to force the link to open the TXT file via Excel instead of Notepad?
 
Oops! Yes. I should have said TXT hyperlink in my subject line.
 
One way is to grab the contents as TextStream object.
Code:
Sub TestTXT()
Set MyData = New DataObject
Dim MyData As DataObject
Dim fso As Scripting.FileSystemObject
Dim ts As Scripting.TextStream
   Set MyData = New DataObject
   Set fso = New Scripting.FileSystemObject
   Set ts = fso.OpenTextFile("C:\gerry\test2.txt")
   MyData.SetText ts.ReadAll
   MyData.PutInClipboard
[COLOR=red yellow]' Just grabbing as string,
' but you can do whatever with that string[/color red yellow]
   MsgBox MyData.GetText(1)

Set MyData = Nothing
Set ts = Nothing
Set fso = Nothing
End Sub

Of course, this will only grab text.

Gerry
See my Paintings and Sculpture
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top