Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
worked yesterday- doesn't work today
Yes....simply add this
If IsEmpty(Sheets(1).Range("B4")) Then MsgBox("Name Not Defined") End If |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
worked yesterday- doesn't work today
If IsEmpty(Sheets(1).Range("B4")) Then
MsgBox("Name Not Defined") End Sub End If |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
File saved yesterday is blank today, how do I retrieve? | New Users to Excel | |||
when i save a file that i have worked on, excel7 closes down work. | Excel Discussion (Misc queries) | |||
Formula to work out hours worked | Excel Discussion (Misc queries) | |||
Formula doesn't work this morning, but worked for 2 years now | Excel Worksheet Functions | |||
countif(a1:a12,">TODAY()") How do I get this to work? | Excel Worksheet Functions |