AW: PDF-Datei unter anderen Namen speichern
12.09.2009 16:54:54
Tino
Hallo,
versuche es mal hiermit, Kommentare stehen im Code.
Option Explicit
Private Declare Function GetShortPathNameA Lib "kernel32" ( _
ByVal lpszLongPath As String, _
ByVal lpszShortPath As String, _
ByVal cchBuffer As Long) As Long
'Pfad Dos kompatibel machen
Public Function ShortPath(ByRef Path As String) As String
Dim n As Long
ShortPath = Space$(256)
n = GetShortPathNameA(Path, ShortPath, 255)
ShortPath = Left$(ShortPath, n)
End Function
Sub CopyFile()
Dim Quelle As String, Ziel As String
'Daten für Quelle ***************************************
Quelle = ShortPath("c:\abc\") 'Pfad Quelle
If Quelle <> "" Then
Quelle = Quelle & Range("A1") 'Quelle + Dateiname aus A1
End If
'Daten für Ziel *****************************************
Ziel = ShortPath("d:\def\") 'Pfad Ziel
If Ziel <> "" Then
Ziel = Ziel & Range("B1") 'Ziel + Dateiname aus B1
End If
If Dir(Ziel) <> "" And Quelle <> "" Then
FileCopy Quelle, Ziel
Else
MsgBox "Fehler beim kopieren, Quelle oder Ziel nicht vorhanden!", vbCritical
End If
End Sub
Gruß Tino