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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Basic Word Macro Help

Status
Not open for further replies.

mogwai88

Technical User
Apr 8, 2002
2
AU
If anyone could help it would be appreciated.

We've got a word document which is an index of all the documents in the folder. It is a table with two fields. One being the document name and the other being the description of the document.

filename1.* | Description 1st table entry
filename2.* | Description 2nd table entry
filename3.* | Description 3rd table entry
etc etc

We now need to create hyperlinks for each entry in the document so the user can click on the file name and the required file will open up automatically.

The problem is there are about 1000 enteries and we don't want to have to manually create the hyperlinks for each one.

I've created a simple word macro to create the hyperlink for each line (assuming the file name is the same) but just need some way of getting the script to insert the file name into the hyperlink function as a variable. The variable needs to get copied from the first column in the document as per table at the top.

This is the macro i have created but can someone explain how i create the variable and how i get the value from the first field in the document into it.

my boss have given this to me and i don't really want to have to go back to him saying i don't know how :)

Thanks



Sub Macro1()
'
' Macro1 Macro
' Macro recorded 30/01/2003 by ******** ******* Group
'
Selection.MoveRight Unit:=wdCell
Selection.MoveRight Unit:=wdCell
ActiveDocument.Hyperlinks.Add Anchor:=Selection.Range, Address:= _
"\\servername\path\filename1.*", SubAddress:="", ScreenTip:="", _
TextToDisplay:="filename1.*"
End Sub


Thanks
 
With your selection mark at the start of the cell, you can use:

selection.moveend wdCell
strFileName=selection.text

then use the strFileName variable in your hyperlink assignment.
Does that help?
Rob
[flowerface]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top