Solved

how to create automatic hyperlinks in microsoft word 2002

Posted on 2004-09-19
12
332 Views
Last Modified: 2012-08-14
i would like to be able to set up microsoft word 2002 (or another application if word can't do this) to automatically convert specific text to hyperlinks (the hyperlinks are to web pages/files) that i have set up.  specifically i would like to be able to do 2 things:

(i) as i write i would like specific words to be converted to hyperlinks that i have already set up for these words.  i am aware that i can get close to this by using the autotext feature.  i.e. i can set up a hyperlink from a given word, then highlight the hyperlinked word, press ALT-F3 and add the word to the 'normal' autotext menu.  then when i type part of the word, the autotext box appears, and i press return to get the full hyperlinked word.  the trouble with this method is that i would like to be able to just keep typing, without having to press return, and still have microsoft word convert the text to its hyperlink. furthermore, i tend to use voice recognition software with microsoft word (dragon naturally), and when i dictate text using this method, the autotext feature won't work, as i am dictating a whole word.  so i wonder if there is some way of automatically converting specific words to predefined hyperlinks as i dictate them.

(ii) for documents that i already have on my pc, i would like to be able to load them into microsoft word, and be able to convert each instance of a given word to its predefined hyperlink.  so here i would be setting up a database/table of words and their associated hyperlinks, and microsoft word would access this to determine which words need converting.  ideally i would be able to convert a whole document with just one click!

i hope this is clear,

thanks,

nick.
0
Comment
Question by:nick_harambee
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
  • 3
  • +2
12 Comments
 
LVL 5

Expert Comment

by:webtrans
ID: 12095504
i Guess the best solution for your Case is using macros
this way you can use it with many words
and with many documents as you like
0
 

Author Comment

by:nick_harambee
ID: 12095520
i am new to macros - how would i set one up to do what i need to do?  and surely macros would only work for part (ii) of my question, as they are something that is applied to text that is already entered.  of course, i could skip part (i) and just make sure i apply the macro once i have finished each document.
0
 
LVL 5

Expert Comment

by:webtrans
ID: 12095551
http://wtonline.vitalnews.com/Pages/Tip0291.html
check the above i guess it might help with the autoformat
still looking for a good document on Macros in word 2002
0
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
LVL 24

Accepted Solution

by:
R_Rajesh earned 500 total points
ID: 12097198
open a new document, copy and paste the following text to it.

The july report at mike?s site has the top10 list.

not hit alt+f11, this opens the vbe. here select module form the insert menu and paste the following code

Type wrdtohyper
sWord As String
sHyper As String
End Type
Sub myConvert()
Dim myLinks(3) As wrdtohyper
Dim i As Integer, fAddress As Double
myLinks(0).sWord = "July Report": myLinks(0).sHyper = "C:\julrep.doc"
myLinks(1).sWord = "Mike's site": myLinks(1).sHyper = "C:\msite.htm"
myLinks(2).sWord = "Top10": myLinks(2).sHyper = "C:\top10.doc"
Selection.Find.ClearFormatting
For i = LBound(myLinks) To UBound(myLinks) - 1
With Selection.Find
.Text = myLinks(i).sWord
If .Execute(Forward:=True, Wrap:=wdFindContinue) Then
fAddress = Selection.Information(5) + Selection.Information(8)
Do
ActiveDocument.Hyperlinks.Add Anchor:=Selection.Range, Address:=myLinks(i).sHyper
.Execute Forward:=True, Wrap:=wdFindContinue
Loop While fAddress <> Selection.Information(5) + Selection.Information(8)
End If
End With
Next i
End Sub

close the vbe, back in word, hit alt+f8, select myconvert and click on run

the wrdtohyper datatype has two variables that holds the words and their corresponding hyperlinks. just add additional words-hyperlink combinaiton to the array

Rajesh
0
 

Expert Comment

by:g_2000
ID: 12097724
Hi..........
     
      Why not download converters, Macros, and use tutorials...Just update your microsoft word so that it will help you solve your problem.....Thanks        
0
 

Author Comment

by:nick_harambee
ID: 12097786
thanks rajesh - i can see how this would work for method (ii).  however is there a slightly more user friendly way of setting this up.  i am thinking of a table with 2 columns with the words that i want to hyperlink in the left column and the path for the files to link to in the right.  would it be possible then to design a macro that could point to this table in order to know what hyperlinks to make?  also, do you know of a way of setting up method (i)?

g 2000 - are you suggesting an alternative method? if so, could you point in the direction of the converters/macros/tutorials that you think will be of help,

thanks

nick.
0
 
LVL 22

Expert Comment

by:Dreamboat
ID: 12099276
After reviewing this question, here's my thinking, Nick.
Forgive me for butting in...

Rajesh has clearly answered your question as it was asked.
Why don't you accept his comment as answer, and ask your more specific question again?
There is nothing so frustrating as writing a whole bit of code for someone, thinking that you know what they want, only to have them *respecify* after the fact.

That's just my thinking tho, Nick.
:)

ALSO...I don't see an alternative, and g_2000's comment makes no sense whatsoever, if you ask me.
Downloading converters, using tutorials, and updating Word won't make a hill o' beans for this specific task you want to perform.

Good luck.
Rajesh is the BEST with Word macros.
If he gets your macro for you and you need help implementing it, send me an email to get me into any question here at EE. Happy to help anyone learn how to USE a macro--they're the greatest when you know how.
0
 

Author Comment

by:nick_harambee
ID: 12100014
thanks for your message dreamboat,

are you suggesting that i accept rajesh's answer, as this is probably the only method of working auto-hyperlinks (i.e. method (i) isn't an option).

then i start a new question requesting a more user friendly way of setting this up.  

i am new to experts exchange and not exactly sure of the protocol.  on other forums, if my questions are related to an existing thread, it seems that others generally prefer me to ask them within this thread so that they can easily view the history.

but i am happy to start a new question and accept rajesh's answer (after all points mean prizes........)

thanks,

nick.
0
 
LVL 22

Expert Comment

by:Dreamboat
ID: 12100110
Points mean prizes? Did they start something new?

Actually, as I said, the question as it was asked has been answered and, while many are happy to give extra information/help, Rajesh pretty much has to rewrite the macro to do it the way you want--like starting over almost.

If you're a premium member, it costs you nothing to accept his answer here (which DOES answer the question asked), and ask a new question.
If you aren't, then I'd be speaking up now if I were you.

See....if you treat the experts good, you won't BELIEVE the stuff they'll do for you.
:)

You might want to review this if you have some time: http://www.experts-exchange.com/Applications/MS_Office/Word/help.jsp#hs4

While the points may not matter--meaning no prizes or anything (unless it's new and I'm not aware of it, which is quite possible), they DO matter, see? I have seen people who are long-time members here at EE ask HARD questions for 25 points, while knowing they were sitting on thousands of points (how did I know? I used to be behind the scenes). After while, experts get used to people, and the points around here, unfortunately, are like THANK YOUS. Of course, if you're profusely appreciative--it accomplishes the same thing. But points are like putting the tip on the bar BEFORE you're served.

Points. Do they mean anything to me? Heck no.
Points. Do they mean anything to anybody else? Maybe to some.
But they're definitely a symbol of what a question's worth is to YOU.
And letting an expert KNOW how much that question is worth to you is very helpful.

Anyway, I'm rambling. It's long past bedtime.
Have a great week y'all!

:)
0
 
LVL 24

Expert Comment

by:R_Rajesh
ID: 12106287
hi DB, thanks... :)

Nick:
as Dreamboat mentioned, i dont think method1 is possible. may be we could use api's to trap the keypress event and check each word entered into word (it wouldn't work with voice recognition though) but coding that will take a really long time...

anyway give this a try. open a new doc, insert a 2 column table. enter your words into first column and hyperlinks in the second. save the doc as C:\hyperwords.doc and close the doc. Now open the file to be converted and run this macro on it.

Type wrdtohyper
sWord As String
sHyper As String
End Type
Sub myConvert()
ReDim myLinks(0) As wrdtohyper
Dim i, fAddress As Double, j, wApp As Object, hDoc As Object
Set wApp = CreateObject("Word.Application")
Set hDoc = wApp.Documents.Open("C:\hyperwords.doc")
For j = 1 To hDoc.Tables(1).Rows.Count
With hDoc.Tables(1).Rows(j)
myLinks(UBound(myLinks)).sWord = .Cells(1).Range.Text
myLinks(UBound(myLinks)).sHyper = .Cells(2).Range.Text
End With
ReDim Preserve myLinks(UBound(myLinks) + 1) As wrdtohyper
Next j
hDoc.Close 0: Set hDoc = Nothing: wApp.Quit: Set wApp = Nothing
Selection.Find.ClearFormatting
For i = LBound(myLinks) To UBound(myLinks) - 1
With Selection.Find
.MatchWholeWord = 0
.Text = Left(myLinks(i).sWord, Len(myLinks(i).sWord) - 2)
If .Execute(Forward:=True, Wrap:=wdFindContinue) Then
fAddress = Selection.Information(5) + Selection.Information(8)
Do
ActiveDocument.Hyperlinks.Add Anchor:=Selection.Range, _
Address:=Left(myLinks(i).sHyper, Len(myLinks(i).sHyper) - 2)
.Execute Forward:=True, Wrap:=wdFindContinue
Loop While fAddress <> Selection.Information(5) + Selection.Information(8)
End If
End With
Next i
End Sub

Rajesh
0
 
LVL 22

Expert Comment

by:Dreamboat
ID: 12106407
Rajesh: Nick made a new Q in which Graham is now trying to help too, but I suspect you're more on the money...
http://www.experts-exchange.com/Applications/MS_Office/Word/Q_21137360.html

Also, Nick doesn't need it to check "as he types", just whenever he hits a toolbar button or something...he wants it to check the entire document...
0
 
LVL 24

Expert Comment

by:R_Rajesh
ID: 12106566
the code i posted does just that but unfortunately in addition to the monitor i mentioned yester day i am also stuck with win95 and office97 (many functions and methods are missing in this version). so I cant test it on 2002 right now. anyway thanks for the link, i will paste the code there as well. maybe Graham can take it form there...
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This tutorial provides instructions on how to properly format your Word document using the inbuilt tools provided. The benefits of using these tools means your documents are more accessible and easily portable to other applications an…
Microsoft Word is a program we have all encountered at some point, but very few of us have dug deep into its full scope of features, let alone customized it to suit our needs. Luckily making the ribbon (aka toolbar, first introduced in Word 2007) wo…
This video walks the viewer through the process of creating envelopes and labels, with multiple names and addresses. Navigate to the “Start Mail Merge” button in the Mailings tab: Follow the step-by-step process until asked to find the address doc…
This video walks the viewer through the process of creating Hyperlinks for the web and other documents. Select the "Insert" tab: Click "Hyperlink":  Type "http://" followed by a web address to reference a website or navigate to a document to ref…

724 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question