Consulting

Results 1 to 3 of 3

Thread: Solved: Application display alert question

  1. #1
    VBAX Regular
    Joined
    Feb 2011
    Posts
    20
    Location

    Solved: Application display alert question

    I have the below code as part of a large code. Everything does what it should be doing but i'm still getting the "save as" promt appearing. I would rather it didnt and simply put the newly renamed file on the user's desktop. I thought the Application.DisplayAlerts True/False would have done it not noooooo

    Dim Fname As String
    Cancel = True
    Application.DisplayAlerts = False
    ChDir "C:\Documents and Settings\All Users\Desktop\"
    Fname = Application.GetSaveAsFilename(ActiveSheet.Range _("AA54").Value, fileFilter:="xls Files (*.xls), *.xls")
    If Fname <> "False" Then
    ActiveWorkbook.SaveAs Fname
    Application.DisplayAlerts = True

    What can i do to kill the Prompt?

  2. #2
    VBAX Expert
    Joined
    Sep 2010
    Posts
    604
    Location
    If you do not want to see a File Name Browser, and if the file name is always based on the value in Range("AA54").Value and you do not want to be prompted when over writing the file, then perhaps something like this:
    [VBA]Private Sub Workbook_BeforeClose(Cancel As Boolean)

    Dim Fname As String

    Application.DisplayAlerts = False

    Fname = "C:\Documents and Settings\UserName\Desktop\" & ActiveSheet.Range("AA54").Value & ".xls"

    ActiveWorkbook.SaveAs Fname

    Application.DisplayAlerts = True

    End Sub[/VBA]

  3. #3
    VBAX Regular
    Joined
    Feb 2011
    Posts
    20
    Location
    Muuuuuch better. Thanks Frank!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •