Hello there,
I was fortunate enough to find this code written by Joe4 which I customized just sligtly. But I am unable to save using .xlsm format.
Any ideas? Saving .xlsx works fine.
Thanks
It hags on the SaveAs line with:
"Run-time error '1004' This file ext cannot be used with the selected file type. Change the file ext, etc
I was fortunate enough to find this code written by Joe4 which I customized just sligtly. But I am unable to save using .xlsm format.
Any ideas? Saving .xlsx works fine.
Thanks
Code:
Sub Copy2_NewWB()
Dim mySourceWB As Workbook
Dim mySourceSheet As Worksheet
Dim myDestWB As Workbook
Dim myNewFileName As String
Dim nSName As String
sName = Range("B1")
' First capture current workbook and worksheet
Set mySourceWB = ActiveWorkbook
Set mySourceSheet = ActiveSheet
' Build new file name based
myNewFileName = mySourceWB.Path & "\" & sName & ".xlsm"
' Add new workbook and save with name of sheet from other file
Workbooks.Add
ActiveWorkbook.SaveAs Filename:=myNewFileName
Set myDestWB = ActiveWorkbook
' Copy over sheet from previous file
mySourceWB.Activate
Cells.Copy
myDestWB.Activate
Range("A1").Select
ActiveSheet.Paste
Application.CutCopyMode = False
' Resave new workbook
ActiveWorkbook.Save
End Sub
It hags on the SaveAs line with:
"Run-time error '1004' This file ext cannot be used with the selected file type. Change the file ext, etc