VBA code to remove external links in Excel 365 fails due to Microsoft patch updates.
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.
Screenshots below.
/* partial code only */
Dim strPath As String
Dim strFileName As String
Dim wkb, wkbDisk As Workbook
Dim boolAlert As Boolean
Dim astrLinks As Variant
Dim iCtr As Long
Set wkb = ThisWorkbook
Application.Calculation = xlManual
Application.Calculate
strPath = wkb.Sheets("Working Area").Range("WorkbookPath").Value
strFileName = wkb.Sheets("Working Area").Range("WorkbookName").Value
astrLinks = wkbDisk.LinkSources(Type:=xlLinkTypeExcelLinks)
/* code fails in next portion where it's supposed to break link to */
If IsArray(astrLinks) Then
For iCtr = LBound(astrLinks) To UBound(astrLinks)
wkbDisk.BreakLink Name:=astrLinks(iCtr), _
Type:=xlExcelLinks
Next iCtr
End If
/* end of code containing VBA error */
Call NoNames
astrLinks = wkbDisk.LinkSources(Type:=xlLinkTypeExcelLinks)
'Application.Calculate
If IsArray(astrLinks) Then
For iCtr = LBound(astrLinks) To UBound(astrLinks)
wkbDisk.BreakLink Name:=astrLinks(iCtr), _
Type:=xlExcelLinks
Next iCtr
End If
Sub NoNames()
Dim n As Name
On Error Resume Next
For Each n In ActiveWorkbook.Names
n.Delete
Next n
On Error GoTo 0
End Sub
In main workbook:
When moved over, the formulas with named ranges remain:
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.
Screenshots below.
/* partial code only */
Dim strPath As String
Dim strFileName As String
Dim wkb, wkbDisk As Workbook
Dim boolAlert As Boolean
Dim astrLinks As Variant
Dim iCtr As Long
Set wkb = ThisWorkbook
Application.Calculation = xlManual
Application.Calculate
strPath = wkb.Sheets("Working Area").Range("WorkbookPath").Value
strFileName = wkb.Sheets("Working Area").Range("WorkbookName").Value
astrLinks = wkbDisk.LinkSources(Type:=xlLinkTypeExcelLinks)
/* code fails in next portion where it's supposed to break link to */
If IsArray(astrLinks) Then
For iCtr = LBound(astrLinks) To UBound(astrLinks)
wkbDisk.BreakLink Name:=astrLinks(iCtr), _
Type:=xlExcelLinks
Next iCtr
End If
/* end of code containing VBA error */
Call NoNames
astrLinks = wkbDisk.LinkSources(Type:=xlLinkTypeExcelLinks)
'Application.Calculate
If IsArray(astrLinks) Then
For iCtr = LBound(astrLinks) To UBound(astrLinks)
wkbDisk.BreakLink Name:=astrLinks(iCtr), _
Type:=xlExcelLinks
Next iCtr
End If
Sub NoNames()
Dim n As Name
On Error Resume Next
For Each n In ActiveWorkbook.Names
n.Delete
Next n
On Error GoTo 0
End Sub
In main workbook:
When moved over, the formulas with named ranges remain: