Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Msg Box - User Entry Validation

Hello,

I am writing some vb code which will save a workbook

WB.SaveAs ("MyExcelWorkbook.xls") - Now if I have already run this Macro MS
Excel prompts the user saying "MyExcelWorkbook.xls" already exists do you
want to override. Yes / No / Cancel

If the user clicks 'Yes' everything is fine. However if the user clicks No
or Cancel the code crashes. How do I build in this validation.

Any help would be much appreciated.

AC



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Msg Box - User Entry Validation

Dim ans as Long

ans = vbYes
If dir( "MyExcelworkbook.xls") < "" then _
ans = Msgbox( "Overwrite existing MyExcelworkbooks.xls",vbYesNo)
if ans = vbYes then
WB.SaveAs ("MyExcelWorkbook.xls")
End if

--
Regards,
Tom Ogilvy

"ACase" wrote in message
...
Hello,

I am writing some vb code which will save a workbook

WB.SaveAs ("MyExcelWorkbook.xls") - Now if I have already run this Macro

MS
Excel prompts the user saying "MyExcelWorkbook.xls" already exists do you
want to override. Yes / No / Cancel

If the user clicks 'Yes' everything is fine. However if the user clicks

No
or Cancel the code crashes. How do I build in this validation.

Any help would be much appreciated.

AC





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
ç(User Entry)è can any one explain this pete the greek Excel Discussion (Misc queries) 1 October 17th 09 09:51 PM
Validation list that also allows user entry? Angela Dennis 911 Excel Worksheet Functions 6 July 20th 06 02:33 PM
Auto email - With every new entry on my user form Vikram Excel Discussion (Misc queries) 0 June 19th 06 06:00 AM
Date Tagging User Entry Gary's Student Excel Programming 3 May 18th 05 01:36 AM
Prevent non "validation" user entry No Name Excel Programming 0 April 30th 04 09:58 PM


All times are GMT +1. The time now is 02:48 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"