Hello,
On my spreadsheet we have a submit that users click after they enter all their information and that initiates an excel macro I wrote to save the file to a certain location. Here is the code I am currently using:
As you can see, the file name is saved off of whatever is entered in cell B11. The problem is, sometimes users have to enter characters such as \ / : * ? " < > |into cell B11 and then when they hit the submit button it gives them a confirmation that the file saved successfully even though it didn't because there were one of the characters mentioned above in cell B11.
I tried to figure this out but I can't. I need some code to be written in this macro to still allow the entering of those characters in cell B11 but when they click submit, I need the macro to strip all of the characters above just for the save file name while keeping the characters physically in cell B11.
Any help would be greatly appreciated!
On my spreadsheet we have a submit that users click after they enter all their information and that initiates an excel macro I wrote to save the file to a certain location. Here is the code I am currently using:
Code:
Sub SaveFile()
Dim strFilename, strDirname, strPathname, strDefpath As String
On Error Resume Next ' If directory exist goto next line
strDirname = Range("ED1").Value ' New directory name
strFilename = Range("B11").Value 'New file name
strDefpath = "S:\" 'Default path name
If IsEmpty(strDirname) Then Exit Sub
If IsEmpty(strFilename) Then Exit Sub
MkDir strDefpath & strDirname
strPathname = strDefpath & strDirname & "\" & strFilename 'create total string
ActiveWorkbook.SaveAs Filename:=strPathname, _
FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False
End Sub
As you can see, the file name is saved off of whatever is entered in cell B11. The problem is, sometimes users have to enter characters such as \ / : * ? " < > |into cell B11 and then when they hit the submit button it gives them a confirmation that the file saved successfully even though it didn't because there were one of the characters mentioned above in cell B11.
I tried to figure this out but I can't. I need some code to be written in this macro to still allow the entering of those characters in cell B11 but when they click submit, I need the macro to strip all of the characters above just for the save file name while keeping the characters physically in cell B11.
Any help would be greatly appreciated!