Forumbeitrag
Excel-Version des Fragestellers:
2022
Erfahrungslevel des Fragestellers:
VBA nur mit Recorder
ralf_b,
> du musst doch nur ActiveWorkbook.Path durch Path ersetzen. wobei du path ja erst mit der inputbox füllst in deinem Makro.
Dann erhalte ich ein leeres Eingabefeld.
> Also welche Variable hast du denn "vor"-belegt und wo ???
Ich schrieb:
"...bin nur Hobbyanwender und verfüge über keine Programmierkenntnisse"
Dies ist mein derzeitiger CODE welcher so NICHT funktioniert:
Sub Save_ACTIVE_SHEET_to_specified_PATH()
'
Dim msg$: msg = "Enter the path in which the sheet is to be saved - the file name extension (.xl??) is automatically added according to the file format!"
Path = InputBox(msg, "Choose Filepath", Path)
Select Case Right(Path, 1)
Case ""
GoTo ErrorHandler
Case Is <> "\"
Path = "C:\Everything\Tests\"
End Select
ActiveSheet.Copy
On Error GoTo ErrorHandler
' ActiveWorkbook.SaveAs Filename:=path & ActiveSheet.Name => Excel 2003
' ActiveWorkbook.SaveAs Filename:=path & ActiveSheet.Name, FileFormat:=52 => Excel 2010: The file name extension can be omitted,
' https://www.herber.de/forum/archiv/1380to1384/1380461_Excel_2010_per_makro_tabellenblatt_in_neue_Datei.html => Excel adds them automatically according to the file format.
ActiveWorkbook.SaveAs Filename:=Path & ActiveSheet.Name, FileFormat:=52
ActiveWorkbook.Close Savechanges:=False
Exit Sub
ErrorHandler:
Select Case Err.Number
Case 1004
MsgBox ("Saving was NOT successful! - Check the path...")
ActiveWorkbook.Close Savechanges:=False
Case Else
End Select
End Sub
Als Vorschlag soll dieser Pfad kommen:
Path = "C:\Everything\Tests\"