Anzeige
Anzeige
HERBERS
Excel-Forum (Archiv)
20+ Jahre Excel-Kompetenz: Von Anwendern, für Anwender
Inhaltsverzeichnis

Filecopy, if file is open new name

Forumthread: Filecopy, if file is open new name

Filecopy, if file is open new name
01.11.2016 12:27:51
Steven
Hi, I have a filecopy script, but if the file is open, then it won't save. I would like to write a script that says if the file is open, then save it to name with suffix _V2. The file is created several times during the day I will always overwrite unless the file is open. any help is highly appreciated. (ich kann auch deutsch lesen)
Here the command:
FileCopy "I:\ELC\SAP Data\Templates\PL_Analysis_20161005 - Kopie.xlsx", "I:\ELC\SAP Data\PL_Analysis_" & Format(Date, "yyyy_mm_dd") & ".xlsx"
Anzeige

2
Beiträge zum Forumthread
Beiträge zu diesem Forumthread

Betreff
Datum
Anwender
Anzeige
AW: Filecopy, if file is open new name
01.11.2016 12:56:41
Gerd
Hi Steven,
probiere die SaveAs-Methode.
https://msdn.microsoft.com/de-de/library/office/ff841185.aspx
Gruß Gerd
AW: Filecopy, if file is open new name
01.11.2016 12:59:54
Daniel
Hi
Dim Var As String
Dim i As Long
On Error Resume Next
Do
i = i + 1
If i = 1 Then
Var = ""
Else
Var = " V" & i
Next
Err = 0
FileCopy "I:\ELC\SAP Data\Templates\PL_Analysis_20161005 - Kopie.xlsx", _
"I:\ELC\SAP Data\PL_Analysis_" & Format(Date, "yyyy_mm_dd") & Var & ".xlsx"
Loop While Err  0
on error goto 0
Err is a variable of the system.
If an error happend while "On Error Resume Next" is active, this variable contains der number of the error.
Gruß Daniel
Anzeige
;

Beliebteste Forumthreads (12 Monate)

Anzeige
Anzeige
Anzeige