Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
|
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 2nd, 2007, 03:14 PM
Registered User
 
Join Date: Aug 2007
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Modify Hyperlinks in Excel 2003

Hi, I upgraded to excel 2003 from excel 2000. The 2003 version modified my hyperlinks puting %20 where there had blank spaces. I found why and took care of that problem, but, it didn't change what had been change. So I need to replace the %20 with blank spaces, and since I have thousands to do I was wondering if there was a way to do them all at once with a macro or something.

Thank you

 
Old August 3rd, 2007, 02:29 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 173
Thanks: 0
Thanked 3 Times in 3 Posts
Default

If its the text of the hyperlinks would a find and replace all (Ctrl+h) not do it for you?

If its the link in the hyperlink that's got corrupted then a bit of coding would be required. Try the following (untested by me but should work):

Code:
Option Explicit

Sub EditHyperlinks()

Dim sh As Worksheet
Dim h As Hyperlink
Dim i As Integer

    ' Loop through every sheet in this spreadsheet
    For Each sh In ThisWorkbook.Sheets

        ' Loop through every hyperlink on the sheet
        For Each h In sh.Hyperlinks

            ' Find the first instance of "20%" in the hyperlink's address
            i = InStr(1, h.Address, "20%", vbBinaryCompare)

            ' Loop as there may be more than one instance
            Do Until i = 0

                ' Replace the instance of "20%" that we've found
                h.Address = Left(h.Address, i - 1) & " " & Mid(h.Address, i + 3)

                ' Find any more instances of "20%" in the hyperlink's address
                i = InStr(1, h.Address, "20%", vbBinaryCompare)

            Loop

        Next h

    Next sh

End Sub
Maccas
 
Old August 3rd, 2007, 03:02 AM
Friend of Wrox
 
Join Date: Mar 2007
Posts: 432
Thanks: 0
Thanked 1 Time in 1 Post
Default

nemesis,

Why do you need to replace the %20?? The %20 is the standard for spaces in URLS, I have tested this on
my machine and even with %20's, local addresses open fine..

Rob
The Developing Developer
Currently Working Towards: MCAD C#
My Blog: http://www.robzyc.spaces.live.com
<center>"Nothing can stop the man with the right mental attitude from achieving his goal;
nothing on earth can help the man with the wrong mental attitude".

Thomas Jefferson</center>





Similar Threads
Thread Thread Starter Forum Replies Last Post
C# and excel on 2003 server mrlou88 C# 2005 3 May 23rd, 2007 11:30 PM
Excel Hyperlinks in ASP JoseLuisR Classic ASP Professional 3 December 26th, 2006 12:44 AM
Excel 2003 problems doing compare Samazf BOOK: Excel 2003 VBA Programmer's Reference 0 September 27th, 2006 12:02 PM
Excel 2003 alfmeiggs BOOK: Excel 2003 VBA Programmer's Reference 1 May 18th, 2005 09:35 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.