|
-
Mar 5th, 2010, 02:42 AM
#1
Thread Starter
New Member
[RESOLVED] Checking hyperlinks
Hi,
I am novice using vbscript and I m blocked to write a script for checking hyperlinks in doc file (word)
Maybe someone can help me
I have written a piece of code but I want to automize it.
What I do is checking hyperlinks in a doc file and write the result in a htm file.
For this it's ok
But what I want to do is checking all hyperlinks of all doc files (word) for a whole directory (ex : all word files present in C:\Temp)
I don't know if it's possible (I have more than 100 doc files to check and I don't want to specify manually all fiels to be checked)
This is what I have written :
Const ForReading = 1, ForWriting = 2, ForAppending = 8
Set objWord = CreateObject("Word.Application")
objWord.Visible = FALSE
Set objDoc = objWord.Documents.Open("C:\Temp\auto.doc")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("C:\temp\chklinks.htm", ForWriting, True)
Set colHyperlinks = objDoc.Hyperlinks
For Each objHyperlink in colHyperlinks
objFile.WriteLine "<a href=" & chr(34) & objHyperlink.Address & Chr(34) & ">" & _
objHyperlink.TextToDisplay & "</a href><br>"
Next
objFile.Close
Set objDoc = objWord.Documents.Open("C:\Temp\maison.doc")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("C:\temp\chklinks.htm", ForAppending, True)
Set colHyperlinks = objDoc.Hyperlinks
For Each objHyperlink in colHyperlinks
objFile.WriteLine "<a href=" & chr(34) & objHyperlink.Address & Chr(34) & ">" & _
objHyperlink.TextToDisplay & "</a href><br>"
Next
objFile.Close
Thanks a lot
Sergio
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|