vba saving word file to created folder
ms-word, vba
Solution
Just replace
ActiveDocument.SaveAs "c:\Users\Jabaar\Documents\" & "(strNewFolderName)" + ".doc"
with
ActiveDocument.SaveAs FileName:="c:\Users\Jabaar\Documents\" & strNewFolderName & "\" & Split(ActiveDocument.Name, ".")(0) & ".doc", _
FileFormat:=wdFormatDocument
where `Split(ActiveDocument.Name, ".")(0)` takes current name of file without extension. You could replace it with desired name:
ActiveDocument.SaveAs FileName:="c:\Users\Jabaar\Documents\" & strNewFolderName & "\" & "newFile.doc", _
FileFormat:=wdFormatDocument
Problem
I have written the code below, currently it creates a folder. However I would like to save the same word doc to that folder. Any pointers on where I am going wrong?? Thanks ``` Sub newfold() Dim strNewFolderName As String strNewFolderName = "New Folder " & (Month(Now())) & " " & Year(Now) If Len(Dir("c:\Users\Jabaar\Documents\" & strNewFolderName, vbDirectory)) = 0 Then MkDir ("c:\Users\Jabaar\Documents\" & strNewFolderName) End If Dim PathName As String PathName = ("New Folder " & MonthName(Month(Now())) & " " & Year(Now)) ActiveDocument.SaveAs "c:\Users\Jabaar\Documents\" & "(strNewFolderName)" + ".doc" End Sub ```