したがって、以下のように完全に正常に機能するマクロがあります。データ検証ドロップダウンをループし、各国の pdf をドロップダウンに保存します。しかし、ファイル名に国名 (D14) に加えて日付が含まれるようにマクロを編集しようとすると、実行時エラー 1004 ドキュメントを保存できませんでした。私はVBAに非常に慣れていないので、これを解決する方法がわかりません...助けていただければ幸いです
ステフ
Sub Create_PDFs()
'
' Create_PDFS Macro
'
' Keyboard Shortcut: Ctrl+y
'
Const sheetToExportName = "Graphs"
Const sheetWithCountryList = "Master Sheet"
Const CountryListAddress = "AQ6:AQ38"
Const chosenCountryCell = "D14"
Const sheetWithChosenCell = "Graphs"
Dim CountryList As Range
Dim anyCountry As Range
Set CountryList = _
ThisWorkbook.Worksheets(sheetWithCountryList). _
Range(CountryListAddress)
For Each anyCountry In CountryList
ThisWorkbook.Worksheets(sheetWithChosenCell). _
Range(chosenCountryCell) = anyCountry
ThisWorkbook.Worksheets(sheetToExportName).ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
"N:\International Finance Division\RAT Advanced Economies - Chartpacks\Country Risks\Created PDFs\" & ActiveSheet.Range("D14").Value & " - Country Risk Indicators.pdf" _
, Quality:=xlQualityStandard, IncludeDocProperties:=False, _
IgnorePrintAreas:=False, OpenAfterPublish:=False
Next
Set CountryList = Nothing
End Sub