Ich müsste bei ein paar Datein, welche ich mit Application.filsearch öffne, die Links löschen und die Datei ohne links unter dem selben dateinamen & _values speichern.
hier mal meine Vorbereitung
Sub Öffnen_Details()
Dim iCounter As Integer, XXX() As Workbook, AllLinks As Variant, i As Long
AllLinks = ActiveWorkbook.LinkSources(xlExcelLinks)
With Application.FileSearch
.LookIn = ThisWorkbook.Path & "\XXX"
.SearchSubFolders = False
.Execute msoSortByFileType
.FileType = msoFileTypeExcelWorkbooks
ReDim XXX(1 To .FoundFiles.Count)
For iCounter = 1 To .FoundFiles.Count
For i = LBound(AllLinks) To UBound(AllLinks)
Workbooks.Open Filename:= _
.FoundFiles(iCounter) _
, UpdateLinks:=0
Application.DisplayAlerts = False
ActiveWorkbook.Save
Sheets("LOCAL").Activate
Debug.Print "Breaking link to file " & AllLinks(i)
ActiveWorkbook.BreakLink Name:=AllLinks(i), _
Type:=xlExcelLinks
Sheets("LOCAL").Activate
Application.DisplayAlerts = True
Application.DisplayAlerts = False
Dim StrValue As String
StrValue = "_VALUE"
ActiveWorkbook.SaveAs Filename:=ActiveWorkbook.Path & "\values\" & Left(ActiveWorkbook. _
_Name, Len(ActiveWorkbook.Name) - 4) & StrValue
Application.DisplayAlerts = True
ActiveWorkbook.Close
Next i
Next iCounter
End With
end sub
Ich bekomme aber einen laufzeitfehler 13 - Typen unveträglich bei der zeile For i = LBound(AllLinks) To UBound(AllLinks)
Wenn ich den Script alleine laufen lasse, so wie ich ihn im internet gefunden habe
Option Explicit
Sub testIt()
Dim AllLinks As Variant, i As Long
AllLinks = ActiveWorkbook.LinkSources(xlExcelLinks)
If IsEmpty(AllLinks) Then GoTo XIT
For i = LBound(AllLinks) To UBound(AllLinks)
Debug.Print "Breaking link to file " & AllLinks(i)
ActiveWorkbook.BreakLink Name:=AllLinks(i), _
Type:=xlExcelLinks
Next i
XIT:
End Sub
funktioniert dieser, wo liegt mein denkfehler, ich kann doch 2 For definieren, oder liege ich hier falsch?Wäre echt super, wenn mir jemand auf die Sprünge helfen könnte.
danke vorab
rupert