+ Reply to Thread
Results 1 to 3 of 3

Can we Set Default value for the Excel promt(Y/N)

  1. #1
    SpiderSwamy
    Guest

    Can we Set Default value for the Excel promt(Y/N)

    Hi all,

    Can we Set Default value for the Excel promt, like if its asking that "
    The file already exists do you want to replace the file" .

    can we set the value to "yes " by default..

    if someone have any idea about this, please reply me back.. I am
    waiting for the reply..


    thanks in advance..
    Swamy


  2. #2
    Tim Williams
    Guest

    Re: Can we Set Default value for the Excel promt(Y/N)

    application.displayalerts=false
    'do stuff
    application.displayalerts=true

    Tim


    "SpiderSwamy" <[email protected]> wrote in message
    news:[email protected]...
    > Hi all,
    >
    > Can we Set Default value for the Excel promt, like if its asking that "
    > The file already exists do you want to replace the file" .
    >
    > can we set the value to "yes " by default..
    >
    > if someone have any idea about this, please reply me back.. I am
    > waiting for the reply..
    >
    >
    > thanks in advance..
    > Swamy
    >




  3. #3
    GS
    Guest

    RE: Can we Set Default value for the Excel promt(Y/N)

    If the prompt you're referring to is, in fact, the "system" prompt that
    appears when you try to save a new file, or rename a file with an existing
    filename, -you can't suppress it. Excel displays a similar prompt when you
    use "SaveAs" or "SaveCopyAs", which cannot be suppressed with .DisplayAlerts.
    It also displays the "Application-defined or Object-defined" error message if
    the user selects "No" or "Cancel".

    To avoid it from displaying, first check if the filename exists or not. If
    it does, prompt the user for a new name if you don't want to overwrite the
    existing file. If you do want to replace it, delete it before using "SaveAs"
    or "SaveCopyAs" if it exists.

    You can check if a file exists with this function:

    Function bFileExists(fileName As String) As Boolean
    ' Checks if a file exists in the specified folder
    ' Arguments: fileName The fullname of the file
    ' Returns: TRUE if the file exists

    Const sSource As String = "bFileExists()"

    On Error Resume Next
    bFileExists = (Dir$(fileName) <> "")

    End Function

    To use it requires the full path and filename passed as a string, as follows:

    If bFileExists(szFullName) Then... 'do something
    -OR-
    If Not bFileExists Then... 'do something

    where szFullName is a string variable containing the full path and filename.

    HTH
    Regards,
    GS

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1