Run Time Error 1004

bloodmilksky

Board Regular
Joined
Feb 3, 2016
Messages
202
Hi Guys,

I am using the below to save sheets as workbooks but it gives me a run time error 1004 saying this file cant be saved using the extension I have requested but my understanding is that .xlsm is the correct extension

Code:
Sub Export_Sheet_To_Order_File()
Dim wb As Workbook
Dim myPath As String
Dim myFilename As String
Dim myFileExtension As String
Dim Msg As String
Dim Ans As VbMsgBoxResult


    myPath = "\\EUCORP-FCL-CM01\cmdeptdata$\custsrv\CS"    'you can change this
    myFileExtension = ".xlsm"
    myFilename = ThisWorkbook.Sheets("EDIorder").Range("A2").Value
    ThisWorkbook.Sheets("EDIorder").Copy
    Set wb = ActiveWorkbook
    With wb
    .ActiveSheet.UsedRange.Value = .ActiveSheet.UsedRange.Value
    .SaveAs myPath & myFilename & myFileExtension
    .Close False
    End With


 Msg = "Would You Like To Load Another Order ? " & Application.UserName
    Ans = MsgBox(Msg, vbYesNo)
    If Ans = vbNo Then
                Range("BP_No").Select
                Selection.ClearContents
                Range("Customer_Order_Number").Select
                Selection.ClearContents
                Range("Description").Select
                Selection.ClearContents
                Application.DisplayAlerts = False
                ThisWorkbook.Save
                Application.DisplayAlerts = True
                Application.Quit
                End If
    
    If Ans = vbYes Then
                Sheets("EDIorder").Select
                Range("A1:X600").Select
                Selection.ClearContents
                Sheets("Order Sheet").Select
                Range("Description").Select
                Selection.ClearContents
                Range("PXINFOR").Select
                Selection.ClearContents
                Range("BP_No").Activate
                Range("BP_No").Select
                End If


End Sub

can anyone help? please
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
Assuming you have a valid file name in myFilename, you need a path separator and the specification of a file format. Try:
Code:
.SaveAs myPath & Application.Pathseparator & myFileName & myFileExtension, Fileformat:=52
 
Upvote 0
Try also specifying the file format with the FileFormat argument.
Code:
    .SaveAs myPath & myFilename & myFileExtension, FileFormat:=xlOpenXMLWorkbookMacroEnabled
 
Upvote 0

Forum statistics

Threads
1,214,599
Messages
6,120,449
Members
448,966
Latest member
DannyC96

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