M
mrburke1
I have a word document containing several INCLUDETEXT links to word
documents hosted on a Web server. These links have the following
form:
{INCLUDETEXT "http://mydomain.com/dir/mydoc.doc" }
I need to automatically update each of these links to include the
latest contents in my target document when the target document is
opened. I have accomplished this by creating an AutoOpen macro in the
target document with the following code:
' Loop through each field contained in the file
For Each fld In ActiveDocument.Fields
Dim status As String
status = fld.Update
MsgBox "Update status: " & status
End With
Next fld
I know that I could do this more easily by simply using the following
code:
Selection.WholeStory
Selection.Fields.Update
Selection.HomeKey Unit:=wdStory
However, I have an additional requirement to only update each field if
the file name/URL actually exists. Basically, I do not want to update
the field if the URL contained in the field is invalid. At this
point, I am unsure how to validate if a URL exists. I can extract the
URL from the field using the following code:
With fld
Dim fileName As String
fileName = .LinkFormat.SourcePath
End With
However, I'm unsure what to do with this URL to validate it.
Any help would be greatly appreciated.
Thank you,
- Mike
documents hosted on a Web server. These links have the following
form:
{INCLUDETEXT "http://mydomain.com/dir/mydoc.doc" }
I need to automatically update each of these links to include the
latest contents in my target document when the target document is
opened. I have accomplished this by creating an AutoOpen macro in the
target document with the following code:
' Loop through each field contained in the file
For Each fld In ActiveDocument.Fields
Dim status As String
status = fld.Update
MsgBox "Update status: " & status
End With
Next fld
I know that I could do this more easily by simply using the following
code:
Selection.WholeStory
Selection.Fields.Update
Selection.HomeKey Unit:=wdStory
However, I have an additional requirement to only update each field if
the file name/URL actually exists. Basically, I do not want to update
the field if the URL contained in the field is invalid. At this
point, I am unsure how to validate if a URL exists. I can extract the
URL from the field using the following code:
With fld
Dim fileName As String
fileName = .LinkFormat.SourcePath
End With
However, I'm unsure what to do with this URL to validate it.
Any help would be greatly appreciated.
Thank you,
- Mike