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
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
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
 
Upvote 0

Forum statistics

Threads
1,214,833
Messages
6,121,868
Members
449,053
Latest member
Mesh

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
Back
Top