zuvor fragte ich eine Frage zum Speichern einer Excel-Datei an einem bestimmten Speicherort mit XLDialogaveAs (die für Dateien funktioniert, die noch gespeichert werden müssen) - Excel VBA XLDialogSaveAs function not working. Ich versuche jedoch, das Gleiche für eine Excel-Datei zu tun, die bereits auf dem Computer gespeichert wurde, aber stattdessen den Speicherort zu ändern.Excel VBA Speichern von Datei im angegebenen Speicherort
Ich habe die folgenden Codes unter:
Option Explicit
Sub externalRatingChangeFile()
'Declare the data type of the variables
Dim wks As Worksheet
Dim sFilename As String
'Set wks to the current active worksheet
Set wks = ActiveWorkbook.ActiveSheet
'Set the location to save the file to a variable
sFilename = "H:\testing file"
'Save as .xlsx file in the specific location stated earlier
'If there are errors in the code, set wks to nothing and end the process
On Error GoTo err_handler
ChDrive sFilename
ChDir sFilename
Application.Dialogs(xlDialogSaveAs).Show (sFilename & "\TestingFile - " & Format(Date, "YYYYMMDD") & ".xlsx")
'System to/not display alerts to notify Users that they are replacing an existing file.
Application.DisplayAlerts = True
err_handler:
'Set Wks to its default value
Set wks = Nothing
End Sub
Kennt jemand die VBA-Funktion übertreffen kann ich den Speicherort der Excel-Datei zu ändern, verwenden und zeigt die bezeichnete Stelle im Dialogfeld vor dem Speichern? Vielen Dank!
Siehe SaveAs wird keine Zeichenfolgen, die enthalten "." In Excel VBA [] (http://stackoverflow.com/questions/36320580/saveas-wont-accpet-strings-that-contain-in-excel-vba/36320966 # 36320966). – Jeeped
Vielen Dank! @Jeeped – JJ2015