保存到%temp%文件夹

时间:2019-03-05 11:45:04

标签: excel vba ms-word

我需要将嵌入的Word文档从Excel保存到Windows%temp%文件夹。我当前的解决方案不起作用。错误在哪里?

Dim tempFolderPath As String
Dim filePath As String
Dim fileTitle As String

    tempFolderPath = Environ("Temp")
    fileTitle = ThisWorkbook.Sheets("Other Data").Range("AK2").Value & ", " & _
    ThisWorkbook.Sheets("Other Data").Range("AK7").Value & "_" & _
    ThisWorkbook.Sheets("Other Data").Range("AK8").Value & "_" & _
    ThisWorkbook.Sheets("Other Data").Range("AU2").Value
    objWord.SaveAs2 filePath = tempFolderPath & "\" & fileTitle & ".docx"

1 个答案:

答案 0 :(得分:1)

SaveAs2方法没有名为filePath的属性。我认为您正在寻找FileName

尝试一下:

objWord.SaveAs2 FileName:= tempFolderPath & "\" & fileTitle & ".docx"

希望这会有所帮助!