Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / November 2007

Tip: Looking for answers? Try searching our database.

Display alert problem

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
carl - 29 Nov 2007 19:19 GMT
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.
Gleam - 29 Nov 2007 20:28 GMT
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

> 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
[quoted text clipped - 14 lines]
> Otherwise I fear one day someone will choose Yes and they will send out the
> previous months workbooks again.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.