.xlsファイルを.xlsxファイル形式のハードコードされた場所に自動的に保存しようとしています。 SaveAsダイアログに、ハードコードされた場所と「ファイル名:」フィールドにコード化されているファイル名が表示されます。これは、保存ボタンをクリックするだけです。Excel VBA XLDialogSaveAs関数が機能しません
ただし、ファイルをHドライブに保存するときに、[名前を付けて保存]ダイアログボックスが常にCドライブを表示するようになります。
次は私のコードです:代わりに名前を付けて保存]ダイアログボックスを示すの
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
ブックまたはワークシートを保存しようとしていますか?ダイアログボックス(xlDialogSaveAs)は、ワークブックが以前に保存されていない場合にのみ、最初のフォルダから開始されます。 – Jeeped
私はブックを保存しようとしています。ブックはオンラインソースからエクスポートされ、以前にフォルダに保存されていません。なぜSaveAsダイアログが私にCドライブを表示し続けるのか? – JJ2015