PC Review


Reply
Thread Tools Rate Thread

Display alert problem

 
 
carl
Guest
Posts: n/a
 
      29th Nov 2007
I'm having problems with display alerts that I'm not sure is fixable. I have
a macro that lets your choose a date from a form and then from that it takes
data from one workbook and copies it in to three other workbooks. It then
saves, closes and emails them to certain distribution lists. The problem is
that the form allows the user to potentially pick a previous month that has
already been saved and emailed. If it does then it comes up with an alert
asking the user if they want to overwrite the workbook that already exists.
But for me I would prefer to not even give the user an option. Is there a
way of writing an If statement that says:

If this alert comes up then end the sub and close the workbooks that were
opened and created without saving Else continue running.

Or just something that will basically also choose No when it ask if the user
wants to over write the existing workbook.

Otherwise I fear one day someone will choose Yes and they will send out the
previous months workbooks again.

 
Reply With Quote
 
 
 
 
Gleam
Guest
Posts: n/a
 
      29th Nov 2007
I think that this may do what you require:

Sub macro3()
fileSaveName = Application.GetSaveAsFilename
If fileSaveName <> False Then
' look to see if filename has already been used
n1 = InStrRev(fileSaveName, "\")
fileShtNm = Right(fileSaveName, Len(fileSaveName) - n1)
filePath = Left(fileSaveName, n1 - 1)
Set fs = Application.FileSearch
With fs
.LookIn = filePath
.Filename = fileShtNm
If .Execute > 0 Then
MsgBox "This file has already been saved."
Else
ActiveWorkbook.SaveAs Filename:=fileSaveName
End If
End With
End If
End Sub


"carl" wrote:

> I'm having problems with display alerts that I'm not sure is fixable. I have
> a macro that lets your choose a date from a form and then from that it takes
> data from one workbook and copies it in to three other workbooks. It then
> saves, closes and emails them to certain distribution lists. The problem is
> that the form allows the user to potentially pick a previous month that has
> already been saved and emailed. If it does then it comes up with an alert
> asking the user if they want to overwrite the workbook that already exists.
> But for me I would prefer to not even give the user an option. Is there a
> way of writing an If statement that says:
>
> If this alert comes up then end the sub and close the workbooks that were
> opened and created without saving Else continue running.
>
> Or just something that will basically also choose No when it ask if the user
> wants to over write the existing workbook.
>
> Otherwise I fear one day someone will choose Yes and they will send out the
> previous months workbooks again.
>

 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
DISPLAY ALERT Faraz A. Qureshi Microsoft Outlook Discussion 1 23rd Jun 2009 02:25 PM
display an alert only once AAaron123 Microsoft ASP .NET 9 11th Aug 2008 02:32 PM
Display Alert =?Utf-8?B?RnJhbmtKSU4=?= Microsoft Excel Programming 4 10th Nov 2005 03:30 AM
Re: Alert Display Sue Mosher [MVP-Outlook] Microsoft Outlook VBA Programming 0 28th Jul 2004 02:58 PM
Display alert =?Utf-8?B?d3phcQ==?= Microsoft Excel Worksheet Functions 2 6th May 2004 07:41 AM


Features
 

Advertising
 

Newsgroups
 


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