rjplante
Well-known Member
- Joined
- Oct 31, 2008
- Messages
- 574
- Office Version
- 365
- Platform
- Windows
I have some code that launches when a cell is changed. The code breaks on the line below highlighted in red.
ActiveWorkbook.SaveAs Filename:=sFilename, FileFormat:=52
The error message reads: Run-time error '1004': The following solutions are listed: does folder exist? Is folder read only? Is name more than 218 characters? Make sure there are the following symbols are not in the name <>?[]:|or*.
None of these issues seem to apply unless I am missing something in the name formula. I don't know what the error is that I need to address.
Thanks for the help.
Robert
ActiveWorkbook.SaveAs Filename:=sFilename, FileFormat:=52
The error message reads: Run-time error '1004': The following solutions are listed: does folder exist? Is folder read only? Is name more than 218 characters? Make sure there are the following symbols are not in the name <>?[]:|or*.
None of these issues seem to apply unless I am missing something in the name formula. I don't know what the error is that I need to address.
Thanks for the help.
Robert
Rich (BB code):
'Specify directory
sPath = "\\Ferrari\common\Product QC\BioPrep QC\PrepaCyte-CB\PrepaCyte-CB QC\510k Lot Testing\Bag 3 Cryobag testing\" & Format(Date, "yyyy") & "\"
SetAttr sPath, vbNormal
If Dir(sPath, vbDirectory) = "" Then
MkDir sPath
ChDir sPath
'Define Name
sFilename = sPath & Format(Sheets("QC5003.17 Cryobag Testing Main").Range("E3").Value, "mm-dd-yy") & " Cryobag Testing on Origen LOT " & Sheets("QC5003.17 Cryobag Testing Main").Range("L3").Value & " by " & Sheets("QC5003.17 Cryobag Testing Main").Range("E2").Value & ".xlsm"
SetAttr sFilename, vbNormal
ActiveWorkbook.SaveAs Filename:=sFilename, FileFormat:=52
'Displays a message box indicating the filename that was used top save the file.
MsgBox ("File was saved with the following name:" & Format(Sheets("QC5003.17 Cryobag Testing Main").Range("E3").Value, "mm-dd-yy") & " Cryobag Testing on Origen LOT " & Sheets("QC5003.17 Cryobag Testing Main").Range("L3").Value & " by " & Sheets("QC5003.17 Cryobag Testing Main").Range("E2").Value & ".xlsm")
Else
'Check to see if file already exists
If ActiveWorkbook.Name = sFilename Then
ActiveWorkbook.Save
Exit Sub
Else
ActiveWorkbook.SaveAs Filename:=sFilename, FileFormat:=52
MsgBox ("File was saved with the following name:" & Format(Sheets("QC5003.17 Cryobag Testing Main").Range("E3").Value, "mm-dd-yy") & " Cryobag Testing on Origen LOT " & Sheets("QC5003.17 Cryobag Testing Main").Range("L3").Value & " by " & Sheets("QC5003.17 Cryobag Testing Main").Range("E2").Value & ".xlsm")