Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / November 2007

Tip: Looking for answers? Try searching our database.

Creating a hyperlinked document based on folder contects

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Steve L - 15 Nov 2007 18:53 GMT
I would like to know if it is possible to have a document read a folders
contents and create hyperlinks to the files in that folder based on the file
name.

Thanks,
Steve
Steve Yandl - 15 Nov 2007 22:56 GMT
You can try this subroutine.  Just change "C:\Test" to the actual target
folder where you want to hyperlink to files.  I have it set up to use the
file name as the text show which is what I think you wanted from your
question and I set it up so each link is a new paragraph.

_________________________________

Sub HyperToFldrFiles()

Dim strTgtFldr As String
Dim strShow As String

' Designate the folder where files are found
strTgtFldr = "C:\Test"

Set fso = CreateObject("Scripting.FileSystemObject")
Set fldTarget = fso.GetFolder(strTgtFldr)

Selection.TypeParagraph

For Each myFile In fldTarget.Files
strShow = fso.GetFileName(myFile)
ActiveDocument.Hyperlinks.Add Anchor:=Selection.Range, _
  Address:=myFile, TextToDisplay:=strShow
Selection.TypeParagraph
Next myFile

End Sub
__________________________________

Steve Yandl

>I would like to know if it is possible to have a document read a folders
> contents and create hyperlinks to the files in that folder based on the
[quoted text clipped - 3 lines]
> Thanks,
> Steve
Steve L - 19 Nov 2007 14:01 GMT
Thanks!  That worked great.

Steve

> You can try this subroutine.  Just change "C:\Test" to the actual target
> folder where you want to hyperlink to files.  I have it set up to use the
[quoted text clipped - 35 lines]
> > Thanks,
> > Steve
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.