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

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
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,223,162
Messages
6,170,432
Members
452,326
Latest member
johnshaji

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