vba save as xlsm does not want to work on excel template

gint32

Board Regular
Joined
Oct 8, 2014
Messages
139
Hi can anyone explain to me why when I open a template(xltm)
the below code when actioned on change does want to run as it halts at with a file type Extension issue

ie .SaveAs "P:\Archives" & Dname with a message stating :

This extension can not be used with the selected file type, change the file extension in the filename to a different file type by choosing save as.

If any one knows a work around or suggestion can they please post as I need to save the file with the macros included for obvious reasons. many thanks in advance



Code:
        If Sh Is Nothing Then
                If Target.Column = 12 Or Target.Column = 15 Then  ' 3'rd and 4th columns are active


        Dname = Format(Now, "dd-mmm-yy") & ".xlsm"
        Dname = "Industry_" & Dname
            Worksheets("Industry").Activate
           
                    With ActiveWorkbook
                
                        .SaveAs "P:\Archives\" & Dname
                        .SaveAs "C:\Users\tom\Desktop\" & Dname 'Can be a variable
                        '.Close 0 ' this would close the workbook
                
                    End With
            
                        'Now Call RDB_Workbook_To_PDF
                Application.Run ("RDB_Workbook_To_PDF")
    
                     
                End If
 
        End If
 
Last edited:

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
Try:

Change:
Code:
[COLOR=#574123]Dname = Format(Now, "dd-mmm-yy") & ".xlsm"[/COLOR]
to
Code:
[COLOR=#574123]Dname = Format(Now, "dd-mmm-yy")[/COLOR]

and change:

Code:
[COLOR=#333333].SaveAs "P:\Archives\" & Dname[/COLOR]
to
Code:
[COLOR=#333333] .SaveAs "P:\Archives\" & Dname[/COLOR][COLOR=#333333], [/COLOR]xlOpenXMLWorkbookMacroEnabled
 
Upvote 0

Forum statistics

Threads
1,213,504
Messages
6,114,016
Members
448,543
Latest member
MartinLarkin

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