+ Reply to Thread
Results 1 to 4 of 4

VBA code to remove external links in Excel 365 fails due to Microsoft patch updates after

  1. #1
    Registered User
    Join Date
    07-12-2022
    Location
    San Francisco, California, USA
    MS-Off Ver
    365
    Posts
    2

    VBA code to remove external links in Excel 365 fails due to Microsoft patch updates after

    Reposted from a different forum. Had a number of views in a different forum, but no comments:

    Long story short: I had code that has been working for years that suddenly breaks due to Microsoft patch update. The VBA code I wrote copies several worksheets to a new workbook. I have links with named ranges which were able to normally convert to hard-coded values upon breaking the link, and now doesn't break and I'm getting "$NAME?" errors everywhere. I have tried to change security settings for macro security "Enable VBA macros (not recommended; potentially dangerous code can run)", but that fails too.

    Any comments or suggestions are appreciated!

    This is the code which worked, but now fails:

    astrLinks = wkbDisk.LinkSources(Type:=xlLinkTypeExcelLinks)

    If IsArray(astrLinks) Then
    /* code fails in next portion where it's supposed to break link to */
    For iCtr = LBound(astrLinks) To UBound(astrLinks)
    wkbDisk.BreakLink Name:=astrLinks(iCtr), _
    Type:=xlExcelLinks
    Next iCtr
    End If
    /* end of code containing VBA error */

  2. #2
    Registered User
    Join Date
    01-11-2023
    Location
    Seattle, Wa
    MS-Off Ver
    365
    Posts
    2

    Cool Re: VBA code to remove external links in Excel 365 fails due to Microsoft patch updates af

    I have run into a similar issue. This is the code I used to fix it. You may need to make some adjustments but it will give you a good start.
    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    07-12-2022
    Location
    San Francisco, California, USA
    MS-Off Ver
    365
    Posts
    2

    Re: VBA code to remove external links in Excel 365 fails due to Microsoft patch updates af

    Hi beginnerVGAmoron,

    First, thank you very much for taking the time to respond. I had long given up on this issue after months of no response, so now I just copy and value paste the sheets, but unfortunately loses the formulas.

    I tried to copy the exact code (3 subroutines) and called "Find_namedrange_place". The stand-alone code doesn't work as several variables are not declared, so I guessed what they should be declared to:

    Dim Destwb As Workbook ' 1/11/2023 GDC Need to add this line to make it work
    Dim I As Long ' 1/11/2023 GDC Need to add this line to make it work
    Dim ExternalLinks As Variant ' 1/11/2023 GDC Need to add this line to make it work
    Dim NmArray As Variant ' 1/11/2023 GDC Need to add this line to make it work
    Dim NmArrayDel As Variant ' 1/11/2023 GDC Need to add this line to make it work
    Dim nm As Name ' 1/11/2023 GDC Need to add this line to make it work
    Dim NmdRng As Variant ' 1/11/2023 GDC Need to add this line to make it work

    The code finally ran, but didn't clear the errors I had before, so I'm probably missing something. Can you give me a high-level understanding of what the subroutines are doing? Maybe that will help me modify my code.

    Thank you again!

    Garland

  4. #4
    Registered User
    Join Date
    01-11-2023
    Location
    Seattle, Wa
    MS-Off Ver
    365
    Posts
    2

    Re: VBA code to remove external links in Excel 365 fails due to Microsoft patch updates af

    Thank you for the updates I wasn't using option explicit and must have gotten sloppy.

    The basics of the code are that
    Line 2 makes sure that the work book doesn't calc and will cause the ranges to break
    Lines 14-23 Breaks external links not attributable to named ranges
    Lines 27-43 Gets the "Names" of the named ranges and then gets the named ranges and stores them in the lists for later
    Lines 48-80 Finds the cells that use external named ranges and then sets them to their values
    Lines 82-84 Deletes the named ranges from the work book

    You need call this code each time a new worksheet is copied into the book. You could make the sheet a variable and then use that for xShName.
    Make sure the workbook is not being calculated during this process (Application.Calculation = xlCalculationManual this should be used as early as possible in your code you can set it back to auto at the end if wanted)
    Make sure that the names of the named ranges are in NmArray can be checked after line 56 with Debug.Print(NmdRng)

+ 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. Break External Links & Remove External Named Ranges
    By Cobra17 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-11-2022, 01:30 PM
  2. VBA Code for finding all external links in an Excel workbook
    By 6StringJazzer in forum Tips and Tutorials
    Replies: 6
    Last Post: 12-08-2019, 12:12 AM
  3. ADO Recordset fails when SAP patch 10 install in local system.
    By Pushpa Sharma in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-24-2017, 03:56 AM
  4. Completely remove/delete all the external links (Break Links)
    By SunOffice in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-23-2014, 05:31 AM
  5. Need a macro that updates external links every 5 minutes
    By mk3ll00 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-05-2013, 01:34 PM
  6. [SOLVED] best way to remove external links
    By Gary Keramidas in forum Excel Programming / VBA / Macros
    Replies: 18
    Last Post: 12-21-2005, 04:10 AM
  7. Replies: 2
    Last Post: 02-04-2005, 08: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