+ Reply to Thread
Results 1 to 2 of 2

Need help with changing hyperlink addresses

Hybrid View

  1. #1
    Registered User
    Join Date
    10-27-2010
    Location
    Salisbury, Maryland
    MS-Off Ver
    Excel 2010
    Posts
    42

    Need help with changing hyperlink addresses

    I've used similar code like what I have below with much success. However, this time the hyperlinks changed such that they have the "%20" in the address for spaces. I need to get the "%20" replaced with spaces and get the first part of that file path changed to the new string I have specified. When I run the code I get the error "Run-time error '7': Out of Memory at the line that after "Else". I have no clue what I have wrong here. Any help would be much appreciated. Thanks, SS

    This post is cross-posted here: https://www.mrexcel.com/board/thread...esses.1210166/

    Sub FixPOHyperlinks()
    
        Dim wBook As Workbook
        Dim wSheet As Worksheet
        Dim tb As ListObject
        Dim OldStr As String, NewStr As String
        Dim hyp As Hyperlink
        Dim sOldAddress As String, sNewAddress As String
    
        Set wBook = ThisWorkbook
        Set wSheet = wBook.Sheets("Sheet1")
        Set tb = wSheet.ListObjects("Table1")
    
        Worksheets("Sheet1").Activate
    
        OldStr = "https://companyname-my.sharepoint.com/personal/mescobal_companyname_com/Documents/H%20drive"
        NewStr = "\\abc.local\DEM"
        
        For Each wSheet In Worksheets
           
            For Each hyp In tb.ListColumns("Machine PO").DataBodyRange.Hyperlinks
        
                If InStr(1, hyp.Address, "\") > 0 Then
                    hyp.Address = Replace(hyp.Address, OldStr, NewStr)
                    hyp.Address = Replace(hyp.Address, "%20", Chr(32))
                Else
                    hyp.Address = NewStr & "\" & hyp.Address
                End If
        
                'hyp.TextToDisplay = Replace(hyp.Address, OldStr, NewStr)
    
            Next hyp
    
        Next
    
    End Sub
    Last edited by sspatriots; 07-08-2022 at 06:44 PM. Reason: Cross post reference added

  2. #2
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,524

    Re: Need help with changing hyperlink addresses

    Welcome to the forum

    Please attach a sample workbook (not a picture or pasted copy). Make sure there is just enough data to demonstrate your need. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are shown, mock them up manually if necessary.

    Remember to desensitize the data.

    Click on GO ADVANCED and then scroll down to Manage Attachments to open the upload window.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Edit Multiple Hyperlink Addresses
    By jacobhughes in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 07-19-2013, 10:36 AM
  2. Turn addresses into hyperlink
    By resulgul in forum Excel General
    Replies: 3
    Last Post: 06-08-2007, 07:13 AM
  3. Email Hyperlink to multiple addresses.
    By Dave F. in forum Excel General
    Replies: 1
    Last Post: 05-11-2006, 07:55 AM
  4. How to type e-mail addresses *without* getting hyperlink?
    By Jumping Rabbit in forum Excel General
    Replies: 1
    Last Post: 01-13-2006, 11:15 AM
  5. Hiding hyperlink addresses
    By Brisbane Rob in forum Excel General
    Replies: 0
    Last Post: 01-12-2006, 03:42 PM
  6. Hyperlink Addresses
    By TEB2 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-23-2005, 04:06 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1