Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,588
Default Can we Set Default value for the Excel promt(Y/N)

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

Tim


"SpiderSwamy" wrote in message
oups.com...
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   Report Post  
Posted to microsoft.public.excel.programming
GS GS is offline
external usenet poster
 
Posts: 364
Default 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
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Promt when closing Excel Carit Excel Discussion (Misc queries) 0 March 22nd 06 07:55 AM
Comment Text Promt Rob Hargreaves[_2_] Excel Programming 1 June 11th 05 09:05 PM
macro that promt user for input Fercho Excel Programming 1 March 16th 05 04:17 AM
How to promt users to save their work? shirley Excel Programming 1 March 2nd 04 02:43 AM
Printing to Adobe without getting promt for name Danny McCarthy Excel Programming 1 October 29th 03 02:26 PM


All times are GMT +1. The time now is 02:05 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"