VBA, Unable to SaveAs2, Error 438 "Object does not support this property or method"

IanCom

New Member
Joined
Jul 31, 2020
Messages
4
Office Version
  1. 365
Platform
  1. Windows
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
 

Some videos you may like

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.

IanCom

New Member
Joined
Jul 31, 2020
Messages
4
Office Version
  1. 365
Platform
  1. Windows
I cant tell from the above if the code correctly highlighted in Red. Just ion case the error resides with this line:

wdDoc.ActiveDocument.SaveAs2 Filename:=folderPath & "\MeansCalculations" & nm.Name & ".docx", FileFormat:=wdFormatDocumentDefault
 

Watch MrExcel Video

Forum statistics

Threads
1,128,165
Messages
5,629,068
Members
416,363
Latest member
zaveedd

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top