I'm using Office 365. Trying to save each of my named ranges in Excel as their own separate Word docs (docx). I get this error 438 in the line I highlighted in Red. Any help appreciated. It seems like the issue is with wdDoc or activeDocument?
VBA Code:
Sub CopyWorksheetsToWord()
Dim wdApp, wdDoc, nm As Name, folder As FileDialog, folderPath As String
'Get folder location to save files to
Set folder = Application.FileDialog(msoFileDialogFolderPicker)
folder.Show
folderPath = folder.SelectedItems(1)
Debug.Print folderPath
Set wdApp = CreateObject("Word.Application")
Application.ScreenUpdating = False
For Each nm In ActiveWorkbook.Names
Range(nm).Copy
Set wdDoc = wdApp.Documents.Add
wdDoc.Range.Paste
[COLOR=rgb(184, 49, 47)]wdDoc.ActiveDocument.SaveAs2 Filename:=folderPath & "\MeansCalculations" & nm.Name & ".docx", FileFormat:=wdFormatDocumentDefault[/COLOR]
Next nm
End Sub