?
Solved

Editing Word 97 hyperlink addresses under program control.

Posted on 2003-03-23
6
Medium Priority
?
165 Views
Last Modified: 2010-04-07
I am trying to write a program to edit hyperlink addresses in a range of Word 97 documents.  I can read the addresses from the Hyperlinks collection of each document but I can't figure out how to update them as the address field is read only.
I looked at deleting and adding but add requires the object containing the hyperlink and this does not seem to be available from the hyperlink object.

Any help would be appreciated.

Regards

Bob
0
Comment
Question by:beezee
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 9

Expert Comment

by:dmang
ID: 8194901
Hi beezee ...

I use the sub below to convert hyperlinks that refer to .doc files, to hyperlinks that refer to .htm files.
This is contained in a word document, so I do not have to reference the Word object library. Keep in mind that the hyperlink must be tied to some words in the document.

The process does the following:
for each hyperlink.
  if link address contains .doc then
     store the link removing the .doc extension)
     delete the link
     select the initial text and set as anchor
     add the hyperlink at the same location
  end if
next link

Sub convert_link_to_HTM()

    Dim i As Integer, _
        iwords As Integer, _
        ipos As Integer
       
   
    With ActiveDocument
   
        For i = 1 To .Hyperlinks.Count
            ipos = InStr(1, .Hyperlinks(i).Address, ".doc")
            If ipos > 0 Then
                straddr = Left(.Hyperlinks(i).Address, ipos - 1)
                .Hyperlinks(i).Range.Select
                iwords = Selection.Words.Count
                .Hyperlinks(i).Delete
                Selection.MoveRight Unit:=wdWord, Count:=iwords, Extend:=wdExtend
                .Hyperlinks.Add Anchor:=Selection.Range, _
                    Address:=straddr & ".htm", _
                    SubAddress:=""
            End If
        Next i
   
    End With

End Sub
0
 

Author Comment

by:beezee
ID: 8198885
Hi Dmang

Thanks for your reply.  I try your suggestion.

The only possible problem is that some of the hyperlinks are in command buttons embedded in the document.  Do yoy think that your code will handle that?

Regards

Bob
0
 
LVL 9

Expert Comment

by:dmang
ID: 8202410
I'm not sure if those links will be part of the collection. If so, the anchor will likely be different - not being document text.

0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Accepted Solution

by:
beezee earned 0 total points
ID: 8206650
Dmang

Thanks for your reply.

I found that the Hyperlinks(i).Shape is the one I needed.  This even returns hyperlinks in text as well as command buttons.

Regards

Bob
0
 

Expert Comment

by:CleanupPing
ID: 8531779
Hi beezee,
This old question (QID 20560371) needs to be finalized -- accept an answer, split points, or get a refund.  Please see http://www.cityofangels.com/Experts/Closing.htm for information and options.
0
 
LVL 6

Expert Comment

by:GPrentice00
ID: 8958828
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

-->PAQ - with points refunded

Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

GPrentice00
EE Cleanup Volunteer
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses
Course of the Month15 days, 2 hours left to enroll

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question