Hi
I have a strange problem that has just started occuring.
I have a workbook that has a button coded to save the file as a specific name. This button has always worked, but for some reason today is not working as expected.
basically what the button does, is checks somes cells on a worksheet for multiple values, if they are blank then the save as name is listed as "unkown, unknown, unknown"
if the cells contain data, then the save as name is made up of the values of those cells.
Currently, if the cells are blank this is working fine.
However if the cells are populated, when the save as box comes up the save as name is completely blank, where it should have the suggested name showing.
here is my code
The msgbox (initialname) shows the correct values as expected, the Msgbox(Newfile) pops up with False)
I have a strange problem that has just started occuring.
I have a workbook that has a button coded to save the file as a specific name. This button has always worked, but for some reason today is not working as expected.
basically what the button does, is checks somes cells on a worksheet for multiple values, if they are blank then the save as name is listed as "unkown, unknown, unknown"
if the cells contain data, then the save as name is made up of the values of those cells.
Currently, if the cells are blank this is working fine.
However if the cells are populated, when the save as box comes up the save as name is completely blank, where it should have the suggested name showing.
here is my code
VBA Code:
Sub Button9_Click()
Dim ActSheet As Worksheet
Dim ActBook As Workbook
Dim CurrentFile As String
Dim NewFileType As String
Dim NewFile As String
Dim regNo As String
Dim insDate As String
Dim inspector As String
'Dim operator As String
Dim checkbox11 As checkbox
Set checkbox10 = ActiveSheet.CheckBoxes("Check Box 10")
Application.ScreenUpdating = False ' Prevents screen refreshing.
CurrentFile = ThisWorkbook.FullName
NewFileType = "Excel Files 2007 (*.xlsm), *.xlsm," & _
"All files (*.*), *.*"
If IsEmpty(Sheets("Title Page").Range("A17").Value) Then
operator = "Unknown Operator"
Else
operator = Sheets("Title Page").Range("A17").Value
End If
If IsEmpty(Sheets("Title Page").Range("A29").Value) Then
insDate = "Unknown Date"
Else
insDate = Replace(Sheets("Title Page").Range("A29").Value, "/", "-")
End If
If IsEmpty(Sheets("Title Page").Range("A34").Value) Then
inspector = "Unknown Inspector"
Else
inspector = Sheets("Title Page").Range("A34").Value
End If
initialname = operator & " - " & _
insDate & " - " & _
inspector & " - " & " GC"
'regNo & " - " & _
MsgBox (initialname)
NewFile = Application.GetSaveAsFilename( _
InitialFileName:=initialname, _
fileFilter:=NewFileType)
MsgBox (NewFile)
If NewFile <> "" And NewFile <> "False" Then
ActiveWorkbook.SaveAs Filename:=NewFile, _
FileFormat:=52, _
Password:="", _
WriteResPassword:="", _
ReadOnlyRecommended:=False, _
CreateBackup:=False
Set ActBook = ActiveWorkbook
Workbooks.Open NewFile
End If
checkbox10.Value = True
checkbox10.Caption = "File Saved - " & Format(Date, "dd/mm/yyyy")
Application.ScreenUpdating = True
End Sub
The msgbox (initialname) shows the correct values as expected, the Msgbox(Newfile) pops up with False)