dirtychinchilla
Board Regular
- Joined
- Jun 21, 2013
- Messages
- 234
Morning all,
I've pieced the code below to create a Save As dialogue box, with the goal being that the name and file type are already completed for the user. The file name is generated from various other parts of information in the spreadsheet, and in order to eliminate what I thought were illegal characters, I've used the following:
Using the above in conjunction with the below, the Save As dialogue box opens, with the file name and type filled in as planned, and then when I press save I get an error to say "The text: is not a valid file name."
It looks like it's not recognising that a file name has even been entered, but obviously it has.
This is the last piece of this program so I'd really appreciate anyone's input!
Thanks in advance,
Jonathon
I've pieced the code below to create a Save As dialogue box, with the goal being that the name and file type are already completed for the user. The file name is generated from various other parts of information in the spreadsheet, and in order to eliminate what I thought were illegal characters, I've used the following:
Code:
="Service Quote"&CHAR(95)&SUM(Input!$E$11:$E$26)&"xAM SVU"&CHAR(95)&ProjName&CHAR(95)&TEXT(Date,"ddmmyyyy")
Using the above in conjunction with the below, the Save As dialogue box opens, with the file name and type filled in as planned, and then when I press save I get an error to say "The text: is not a valid file name."
It looks like it's not recognising that a file name has even been entered, but obviously it has.
Code:
Sub SaveAs()
Dim varResult As Variant
Dim strName As String
'displays the save file dialog
varResult = Application.GetSaveAsFilename(InitialFileName:=Range("FileName"), FileFilter:="Excel Files (*.xls), *.xls")
'checks to make sure the user hasn't canceled the dialog
If varResult <> False Then
Cells(2, 1) = varResult
End If
InvalidName:
MsgBox "The text: " & strName & " is not a valid file name.", vbCritical
End Sub
This is the last piece of this program so I'd really appreciate anyone's input!
Thanks in advance,
Jonathon