Dynamically/conditionally updating INCLUDETEXT fields

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
 
C

Cindy M.

You might want to try asking this in a group dedicated to internet
programming. This is an end-user-oriented newsgroup, macro questions
should go to a word.vba group, but what you want to do is not something
that VBA supports. It's going to require an external library of some
sort. So a group that supports internet scripting or a classic visual
basic group is probably your best bet. This link gives you access to all
kinds of programming newsgroups

http://msdn.microsoft.com/newsgroups/default.aspx?dg=microsoft.public.of
ficedev&lang=en&cr=US
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.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question
or reply in the newsgroup and not by e-mail :)
 

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