LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 86
Default Use VBA in Excel to Open Word Doc and Create a list of Hyperlinks

I would like to use a routine in Excel to open a Word document from a list
and create a list of the hyperlinks in the document(s).

I can open the word document but I cannot extract the desired hyperlink
information.

Can anyone tell me what is wrong with this code or this methodology?

Sub OpenWordDoc()

Dim WordObj As Object
Dim Fpath As String
Dim LinksList() As Variant
Dim aHyperlink As Hyperlink

Err.Clear
On Error Resume Next

ReDim LinksList(4, 2)

' Set file path
Fpath = "C:\Documents and Settings\UserRoutines\ListHyperlinksTest.doc"

' Open the word document
Set WordObj = CreateObject("Word.Application")
WordObj.Documents.Open (Fpath)
WordObj.Visible = True

' This part works in Word but does not work in Excel
i = 0
For Each aHyperlink In ActiveDocument.Hyperlinks
i = i + 1
LinksList(i, 1) = aHyperlink.TextToDisplay
LinksList(i, 2) = aHyperlink.Address
Next aHyperlink
' End of section that works in Word but does not work in Excel

' Close the file
WordObj.Documents.Close
' Quit Word
WordObj.Quit

End Sub

Thanks in advance,
Raul
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to create a bulleted list within a cell in excel (as in Word) Lenin New Users to Excel 1 November 7th 07 11:31 AM
How to open Excel list in Word for mail merge/labels? Leinani Excel Discussion (Misc queries) 2 March 28th 07 01:58 AM
How do I create a list (Word) of the names on Excel worksheet tabs PT[_2_] Excel Worksheet Functions 3 February 23rd 07 05:24 PM
Create a list box/combo box with hyperlinks Jared Excel Worksheet Functions 0 August 29th 06 07:46 PM
Possible to open word documents in Excel using hyperlinks? DobieM New Users to Excel 2 July 12th 06 04:08 PM


All times are GMT +1. The time now is 05:13 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"