With Application.FileSearch
.NewSearch '--> auf Standardeinstellungen setzen
.LookIn = strPfadnameAktuell
.SearchSubFolders = True
.Filename = oWSBearbeitung.Cells(25, 2)
.MatchTextExactly = True
.FileType = msoFileTypeAllFiles
If .Execute() > 0 Then
.
.
.
For lDateiZaehler = 1 To .FoundFiles.Count
VDatumAktuelleDatei = FileDateTime(.FoundFiles(lDateiZaehler))
[b]
Set oWBExtern = GetObject(.FoundFiles(lDateiZaehler))
[/b]
' bestehende Datei umbenennen
Name strDateiAlt As strDateiNeu
Dir(.FoundFiles(lDateiZaehler ))strPfadnameAktuell
strPfadAktuell = Application.FileSearch.FoundFiles.Item(lDateiZaehler) ' Pfad mit Dateiname
strDateiNameAktuell = Dir(.FoundFiles(lDateiZaehler)) ' Dateiname
strPfadAktuell = Left(strPfadAktuell, (Len(strPfadAktuell) - Len(strDateiNameAktuell))) ' Dateiname aus Pfad herausschneiden
' Benötigte API-Deklaration für Kopierfunktion
Private Declare Function CopyFile Lib "kernel32" _
Alias "CopyFileA" ( _
ByVal lpExistingFileName As String, _
ByVal lpNewFileName As String, _
ByVal bFailIfExists As Long) As Long
.
.
.
' Neue Kopierfunktion "DateiKopieren", Aufruf wie in VBA FileCopy
Public Function DateiKopieren(ByVal sSourceFile As String, _
ByVal sDestFile As String, _
Optional ByVal bAlwaysOverwrite As Boolean = True) As Boolean
Dim nResult As Long
nResult = CopyFile(sSourceFile, sDestFile, CLng(Abs(Not bAlwaysOverwrite)))
DateiKopieren = (nResult <> 0)
End Function
.
.
.
public sub DasEigentilicheMakro
.
DateiKopieren strPfadAktuell & strDateiNameAktuell, strAusgabePfad & strDateiNameAktuell
.
end sub
Excel schließen (VBA)
Jugo 15.03.2007 - 312 Hits - 1 Antwort
Excel VBA: Buchtipps ?
Rolf___ 14.08.2007 - 24 Hits - 1 Antwort
Excel VBA: Datei speichern, Excel beenden und Windows herunterfahren
snailhouse 15.11.2007 - 477 Hits - 1 Antwort
VBA mit Excel - Problem bei Schleife
schmidt206 01.12.2007 - 68 Hits - 4 Antworten
Excel VBA
drphilgonzo 17.01.2008 - 34 Hits - 1 Antwort