Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 96
Default worked yesterday- doesn't work today

heres the code i was using. Yesterday it worked perfectly. I have the email
in my inbox to prove it. Today when i use it i get this error. Run Time Error
1004 Application defined or object defined error. I haven't changed a thing
in the file.

Private Sub Send2_Click()

Dim wb As Workbook
Dim strdate As String
strdate = Format(Now, "dd-mm-yy h-mm-ss")
ActiveSheet.Copy
Set wb = ActiveWorkbook
With wb
.Sheets(1).Name = .Sheets(1).Range("B4").Value
.SaveAs .Sheets(1).Range("B4").Value _
& ".xls"
ActiveWorkbook.SendMail "", _
"Inactive Employee Attendance Data"
ActiveWorkbook.ChangeFileAccess xlReadOnly
Kill ActiveWorkbook.FullName
ActiveWorkbook.Close False
End With
End Sub


Thanks for the help.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 96
Default worked yesterday- doesn't work today

I realized i have no value in B4. Which leads me to this question. If there
is no value in B4 can I fix the macro to bring up a message box that says
"Name Not Defined"?

"Qaspec" wrote:

heres the code i was using. Yesterday it worked perfectly. I have the email
in my inbox to prove it. Today when i use it i get this error. Run Time Error
1004 Application defined or object defined error. I haven't changed a thing
in the file.

Private Sub Send2_Click()

Dim wb As Workbook
Dim strdate As String
strdate = Format(Now, "dd-mm-yy h-mm-ss")
ActiveSheet.Copy
Set wb = ActiveWorkbook
With wb
.Sheets(1).Name = .Sheets(1).Range("B4").Value
.SaveAs .Sheets(1).Range("B4").Value _
& ".xls"
ActiveWorkbook.SendMail "", _
"Inactive Employee Attendance Data"
ActiveWorkbook.ChangeFileAccess xlReadOnly
Kill ActiveWorkbook.FullName
ActiveWorkbook.Close False
End With
End Sub


Thanks for the help.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 133
Default worked yesterday- doesn't work today

Yes....simply add this

If IsEmpty(Sheets(1).Range("B4")) Then
MsgBox("Name Not Defined")
End If

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 96
Default worked yesterday- doesn't work today

How do I also get the macro to quit running if the massage box is displayed?
I'm trying to avoid the user seeing the Run Time error. The message box would
hint the user that a value needs to be placed in B4. So if no value is in B4
then the message box should come up and the macro should stop running.

"Chip" wrote:

Yes....simply add this

If IsEmpty(Sheets(1).Range("B4")) Then
MsgBox("Name Not Defined")
End If


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 133
Default worked yesterday- doesn't work today

If IsEmpty(Sheets(1).Range("B4")) Then
MsgBox("Name Not Defined")
End Sub
End If



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 96
Default worked yesterday- doesn't work today

Heres what it looks like now and i get a compile error.
Appreciate all the help.

Private Sub Send2_Click()

Dim wb As Workbook
Dim strdate As String
strdate = Format(Now, "dd-mm-yy h-mm-ss")
ActiveSheet.Copy
Set wb = ActiveWorkbook
If IsEmpty(Sheets(1).Range("B4")) Then
MsgBox ("Name Not Defined")
End Sub
End If
With wb
.Sheets(1).Name = .Sheets(1).Range("B4").Value
.SaveAs .Sheets(1).Range("B4").Value _
& ".xls"
ActiveWorkbook.SendMail "", _
"Inactive Employee Attendance Data"
ActiveWorkbook.ChangeFileAccess xlReadOnly
Kill ActiveWorkbook.FullName
ActiveWorkbook.Close False

End With
End Sub

"Chip" wrote:

If IsEmpty(Sheets(1).Range("B4")) Then
MsgBox("Name Not Defined")
End Sub
End If


  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 133
Default worked yesterday- doesn't work today

I was stupid...change the "End Sub" in the If Statement to "Exit Sub":

If IsEmpty(Sheets(1).Range("B4")) Then
MsgBox("Name Not Defined")
Exit Sub
End If

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 96
Default worked yesterday- doesn't work today

Works Perfect. Thanks.

"Chip" wrote:

I was stupid...change the "End Sub" in the If Statement to "Exit Sub":

If IsEmpty(Sheets(1).Range("B4")) Then
MsgBox("Name Not Defined")
Exit Sub
End If


  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 863
Default worked yesterday- doesn't work today

I think that should be EXIT SUB, not End Sub.


On 24 Feb 2005 11:36:44 -0800, "Chip" wrote:

If IsEmpty(Sheets(1).Range("B4")) Then
MsgBox("Name Not Defined")
End Sub
End If


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
File saved yesterday is blank today, how do I retrieve? MelB New Users to Excel 2 February 12th 10 03:56 PM
when i save a file that i have worked on, excel7 closes down work. rob Excel Discussion (Misc queries) 2 February 11th 10 07:10 AM
Formula to work out hours worked Shazza Excel Discussion (Misc queries) 4 January 21st 07 11:52 PM
Formula doesn't work this morning, but worked for 2 years now Rhop Excel Worksheet Functions 1 October 11th 06 01:54 PM
countif(a1:a12,">TODAY()") How do I get this to work? Dan Bork Excel Worksheet Functions 1 November 11th 04 10:54 PM


All times are GMT +1. The time now is 08:53 PM.

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

About Us

"It's about Microsoft Excel"