Excel中包含使用VBA的特定单词的中断链接

我试图打破链接中有关键词的所有链接。 我不想破坏每一个环节。 我已经看到了VBA,它必须是一个完整的文件名,以便它的工作,但我想知道是否有办法打破所有只有关键词的链接?

例如,我有4个以下的链接。 我只是想删除关键词“品牌网站预测”的链接,删除有它的3个链接。

每日品牌网站Flash.xlsx

品牌网站预测FY18(AUG).xlsx

品牌网站预测FY18(SEP).xlsx

品牌网站预测FY18(OCT).xlsx

我试过这个,但不起作用:

ActiveWorkbook.BreakLink Name:="Brand Site Forecast", Type:=xlExcelLinks 

但完整的文档名称会这样:

  ActiveWorkbook.BreakLink Name:="Brand Site Forecast FY18 (AUG).xlsx", Type:=xlExcelLinks 

有任何想法吗?

尝试这个

  Sub BreakExternalLinks() Dim ExternalLinks As Variant Dim wb As Workbook Dim x As Long Set wb = ActiveWorkbook 'Create an Array of all External Links stored in Workbook ExternalLinks = wb.LinkSources(Type:=xlLinkTypeExcelLinks) 'Loop Through each External Link in ActiveWorkbook and Break it For x = 1 To UBound(ExternalLinks) 'remove the links with the key words "Brand Site Forecast" If InStr(1, ExternalLinks(x), "Brand Site Forecast", vbTextCompare) > 0 Then wb.BreakLink Name:=ExternalLinks(x), Type:=xlLinkTypeExcelLinks End If Next x End Sub 

感谢Maddy的帮助! 我已经改变了一点VBA,它现在完美。 这里是VBA。

 Sub BreakExternalLinks() Dim ExternalLinks As Variant Dim wb As Workbook Dim x As Long Set wb = ActiveWorkbook 'Create an Array of all External Links stored in Workbook ExternalLinks = wb.LinkSources(Type:=xlLinkTypeExcelLinks) 'Loop Through each External Link in ActiveWorkbook and Break it For x = 1 To UBound(ExternalLinks) 'remove the links with the key words "Brand Site Forecast" If ExternalLinks(x) Like "*Brand Site Forecast*" Then wb.BreakLink Name:=ExternalLinks(x), Type:=xlLinkTypeExcelLinks End If Next x End Sub