我试图设置我的工作簿文件的路径,该文件要从当前工作簿所基于的同一目录中打开。 我在这里看到了一些解决方案:
Open File Without Calling Filepath
我的代码当前如下所示:
Sub RamsOpen3()
Dim appWD As Word.Application
Set appWD = New Word.Application
Dim docWD As Word.Document
Set docWD = appWD.Documents.Open ActiveWorkbook.Path & "RAMS.docx.docm")
appWD.Visible = True
'
' Data is selected and copied into "Design"
'
'Copy all data from Design
Sheets("Frontsheet").Select
Range("D18").Copy
' Tell Word to create a new document
appWD.Selection.Paste
' Save the new document with a sequential file name
Sheets("Sheet1").Select
appWD.ActiveDocument.SaveAs filename:=ThisWorkbook.path & "/" & "TEST" & Range("C8").Text
' Close this new word document
appWD.ActiveDocument.Close
' Close the Word application
appWD.Quit
End Sub
代码行为红色,调试器显示:语句的预期结尾。
它也不包括上面的链接查询中建议的以Dim文件名作为字符串的选项。
有人知道如何应对吗?