Automating Hyperlinks in Word

D

DM2

I use MS Word to create Adobe PDF files that are menu's to technical
documents on our network at work. I have for sometime, been creating the
links manually but this is time consuming and I have a ton of documents. I've
got to believe there is a way to automate this process.

My current process is to use MS Excel and import the directory where a given
group of technical documents are stored into an Excel file. I use Excel to
check the file name length to insure it doesn't exceed a given number of
characters. During this process It easy to use "Search & Replace" to replace
names with abbreviations. For example FIND "Installation" and REPLACE with
"INST". What I end up with is 2 columns. Column A, which has the actual file
name and extension, and Column B which is a description of the file (i.e.
"Siemens_XYX_Cntrl_Inst-Rev_06.PDF" and "Siemens Model XYZ Controller
Installation Manual, Revision 06").

Couldn't a Macro be written in Word that looks at the Excel File and uses
Column A as the HyperLink, and Column B text that's displayed for the
Hyperlink?

Signed...Trying to work smarter, not harder
Regards
Dan
 
O

oshosoul

I use MS Word to create Adobe PDF files that are menu's to technical
documents on our network at work. I have for sometime, been creating the
links manually but this is time consuming and I have a ton of documents. I've
got to believe there is a way to automate this process.

My current process is to use MS Excel and import the directory where a given
group of technical documents are stored into an Excel file. I use Excel to
check the file name length to insure it doesn't exceed a given number of
characters. During this process It easy to use "Search & Replace" to replace
names with abbreviations. For example FIND "Installation" and REPLACE with
"INST". What I end up with is 2 columns. Column A, which has the actual file
name and extension, and Column B which is a description of the file (i.e.
"Siemens_XYX_Cntrl_Inst-Rev_06.PDF" and "Siemens Model XYZ Controller
Installation Manual, Revision 06").

Couldn't a Macro be written in Word that looks at the Excel File and uses
Column A as the HyperLink, and Column B text that's displayed for the
Hyperlink?

Signed...Trying to work smarter, not harder
Regards
Dan

you can use hyperlink collection and range object in word
iterate and add hyperlinks

Thanks
Vivek
 
D

DM2

:

you can use hyperlink collection and range object in word iterate and add
hyperlinks

Thanks
Vivek

Vivek,
Thanks for your input but I'm a bit of a novice at VB. I'm not sure if it's
appropriate for me to ask this, but do you have a sample of what your talking
about?

My Word document would be "Menu_Siemens.doc" and my spreadsheet would be
Menu_Siemens.xls" and located in the same director. The linked files would
be in a sub directory "Manuals"

Regards,
Dan
 
D

Doug Robbins - Word MVP on news.microsoft.com

That certainly can be done, but I would suggest that you simplify the
process and avoid having to work with both Word and Excel, by having the two
columns of data in a table in a Word document.

The other question is - how are you intending to control where the links are
inserted?

What I would suggest doing is having the data loaded into a listbox on a
modeless userform and then when you select the location in the document
where you want to insert the hyperlink, you select the required "link" in
the listbox and then click on a button on the userform to have the hyperlink
created.

Fellow MVP Greg Maxey has accumulated some information on the following
pages of his website on creating a userform and also on loading data into a
listbox from various sources:

http://gregmaxey.mvps.org/Create_and_employ_a_UserForm.htm

http://gregmaxey.mvps.org/Populate_UserForm_ListBox.htm

Assuming that you name the listbox lstLinks, you would use the following
code on a command button on the form to create a hyperlink

Dim lrange as Range
Dim laddress as String, ltext as String
Set lrange = Selection.Range
With lstLinks
.BoundColumn = 1
laddress = .Value
.BoundColumn = 2
ltext = .Value
End With
ActiveDocument.Hyperlinks.Add Range:=lrange, Address:=laddress,
TextToDisplay:=ltext

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top