Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Saving a File Code Question

Status
Not open for further replies.

remeng

Technical User
Jul 27, 2006
520
US
Hi guys,

Could someone take a look at this. It was working the other day and isn't today. The goal is to prompt the user with a msgbox if they want to save. On yes it brings up the save as box. It then saves the file if a name is provided. If they hit cancel it just ends the if statements.

Code:
Dim slotsavemsg As Integer

slotsavemsg = MsgBox("Would you like to save your Slot Analysis?", vbYesNo, "Slot Analysis Save")

If slotsavemsg = vbYes Then

    filesavename = Application.GetSaveAsFilename(filefilter:=("Microsoft Office Excel Workbook (*.xls), *.xls"))
    
    If filesavename = Not (False) Then
    
        ActiveWorkbook.SaveAs filename:=filesavename, FileFormat:=xlNormal
    
    Else
    
    End If

End If
 
I'd replace this:
If filesavename = Not (False) Then
with this:
If Not (filesavename = False) Then

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Thanks! Looks like that might have been the issue. Just a quick follow up. Why whould my previous cod not have worked correctly?

Thanks again!
 
Because Not (False) is equal to True and filesavename is NEVER equal to True.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Thanks! Good to know that's how to read the statement.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top