Getting Corrupted save file, but normal method of solving it doesn't seem to compile

INSTAR

New Member
Joined
Jul 14, 2023
Messages
2
Office Version
  1. 2016
Platform
  1. Windows
Bit of a head scratcher this one.

I have the following code

VBA Code:
Sub SaveName()
Dim File_name As String
Dim Path As String
File_name = Range("AC13")
Path = "C:\Users\admin\Documents\Paint_Mixes\Two_Colour\"
ActiveWorkbook.SaveCopyAs Filename:=Path & File_name & ".xlsx"
MsgBox ("File is saved at " & Path & File_name)
With Range("C2")
.Value = .Value + 1
End With
End Sub

That created a save file, but it was corrupted when trying to open it. So searching on the internet led me to adding a FileFormat as I did here

VBA Code:
Sub SaveName()
Dim File_name As String
Dim Path As String
File_name = Range("AC13")
Path = "C:\Users\admin\Documents\Paint_Mixes\Two_Colour\"
ActiveWorkbook.SaveCopyAs Filename:=Path & File_name & ".xlsx", FileFormat:=xlOpenXMLWorkbook
MsgBox ("File is saved at " & Path & File_name)
With Range("C2")
.Value = .Value + 1
End With
End Sub

But all I get now is "Compile Error - Named Argument not found"

I'm fairly certain it's a simple thing but i'm currently banging my head on the desk trying to figure out what's going on or how to save the file without it being corrupt.
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
Bit of a head scratcher this one.

I have the following code

VBA Code:
Sub SaveName()
Dim File_name As String
Dim Path As String
File_name = Range("AC13")
Path = "C:\Users\admin\Documents\Paint_Mixes\Two_Colour\"
ActiveWorkbook.SaveCopyAs Filename:=Path & File_name & ".xlsx"
MsgBox ("File is saved at " & Path & File_name)
With Range("C2")
.Value = .Value + 1
End With
End Sub

That created a save file, but it was corrupted when trying to open it. So searching on the internet led me to adding a FileFormat as I did here

VBA Code:
Sub SaveName()
Dim File_name As String
Dim Path As String
File_name = Range("AC13")
Path = "C:\Users\admin\Documents\Paint_Mixes\Two_Colour\"
ActiveWorkbook.SaveCopyAs Filename:=Path & File_name & ".xlsx", FileFormat:=xlOpenXMLWorkbook
MsgBox ("File is saved at " & Path & File_name)
With Range("C2")
.Value = .Value + 1
End With
End Sub

But all I get now is "Compile Error - Named Argument not found"

I'm fairly certain it's a simple thing but i'm currently banging my head on the desk trying to figure out what's going on or how to save the file without it being corrupt.
It's ok now, I found a code elsewhere on here that helped :)

Tunrs out SaveAsCopy doesn't allow for FileFormat to be used
 
Upvote 0

Forum statistics

Threads
1,215,110
Messages
6,123,138
Members
449,098
Latest member
Doanvanhieu

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