Excel 2010 :: Macro To Send Email Now Fails With Runtime Error 1004 - Mail System Failure
Aug 23, 2012
I've been using a macro successfully for the last couple of years, but this morning when I went to use it, it decided to fail. I have a workbook which contains various spreadsheets. The macro that has failed performs the following tasks:
1. It copies a list of email addresss from an external workbook to a sheet in the current workbook (still works)
2. It copies the referral sheet I want to send to a new file, and saves it with an appropriate filename to an appropriate folder (still works)
3. The macro then creates an email with a standard subject line, attaches the new worksheet and emails it to each of the addresses as above (broken)
The error message is from Microsoft Visual Basic. "Run-time error '1004': Mail system failure. Check your mail installation."
I'm guessing there is a setting somewhere in Excel that has changed as part of an update.
I've been through a number of the options in the developer menu to remove any obvious restrictions (& reopened excel afterwards), but so far it hasn't resolved the problem.
For what it's worth, here is the macro code.
With Application
.EnableEvents = False
.ScreenUpdating = False
End With
Run "PullInSheet1"
Dim oldbook As String
[Code] .......
In case you're wondering about the pullinsheet code, I'll add it below - but I probably grabbed it from this forum a couple of years ago (like some of the above) & just made some changes.
Code:
Sub PullInSheet1()
Dim AreaAddress As String
'''''' Sheet11.UsedRange.Clear
Dim ClRange As String
ClRange = "= 'L:ADMINEMPLOY SERVICES" _
[Code] ........
There are a couple of things I've wanted to do to improve the macro, but I couldn't justify the need to spend time working it out (since writing spreadsheets isn't really my job). Since it's broken at the moment, I can...
1. I'd like to create a subject line that reflects the name of the person being referred. For some reason though, anything other than text in the cell reference caused an error for me. eg, I tried using concatenate to create my subject line, but it didn't work.
2. I'd like the copied sheet to contain all of the formatting of the original sheet. Presumably there is a paste option that will do this and I just picked the wrong one.
The mailsystem we use is Groupwise 8. I couldn't find any settings in that program that have been changed, or that I could change.
I should change the extension from xls to xlsx in the code since I'm using Excel 2010 (but changing it doesn't fix the problem).
View 4 Replies
ADVERTISEMENT
May 1, 2012
I am using Excel 2010. Why I do struggle with setting the range below
Code:
Set rng = Sheets("Data").Range(Cells(4, firstcol), Cells(lastrow, lastcol))
I get run time error 1004
Tried simple code from msdn and it return same error
Code:
Range(Cells(2, 3), Cells(10, 4)).Select
View 2 Replies
View Related
Jun 25, 2013
I am using this code (below) to hide certain rows or columns depending on what number is entered. Everything is working fine and I am at the point where I would like to share this excel sheet with others but I would like to lock certain cells so that others cannot alter the formulas. As soon as I lock the cells and then enter values into the unlocked cells, I get the "run-time error '1004': Unable to set the Hidden property of the Range class".
I am using excel 2010 x64.
Code:
Private Sub Worksheet_Change(ByVal Target As Range)If Not Intersect(Target, Range("B3")) Is Nothing Then
If Range("B3").Value = 0 Then
Columns("G:P").EntireColumn.Hidden = True
Else
If Range("B3").Value = 1 Then
Columns("H:P").EntireColumn.Hidden = True
[code]....
View 3 Replies
View Related
Jul 31, 2014
The macro I'm writing (Excel 2010) is a loop that inserts a column based on a variable location, enters in a formula in the first cell, enters another formula in cell 2, then should fill that second formula to the last row, then keep going until the loop ends. There is always a chance that there will be blank cells to the left and right so I didn't use xldown. I've tried writing in multiple ways, but I keep getting the error.
Code:
Sub colfrmadd()
Range("A1").CurrentRegion.Select
colcnt2 = Selection.Columns.Count
[Code]....
View 1 Replies
View Related
Nov 20, 2013
I have been given a macro recorded on a mac and it works fine with Mac Excel 2011. Unfortunately, I need to make it to work on a windows machine, but it comes up with an error message "macro unable to set width property of the window class. Run-time error 1004". When I press debug it takes me to the line .Width = 1456.
Below is the chunk of the code that becomes highlighted when pressing debug.
With ActiveWindow
.Width = 1456
.Height = 795
End With
View 3 Replies
View Related
Jul 1, 2014
I have set of send mail Performance from excel through outlook ... I have facing error like
"Run-Time error '-2147467259 (80004005)':
Array lower bound must be zero.
Attachment :
rte.jpg
RuntimeError.xlsb
View 4 Replies
View Related
Jan 24, 2012
what is the proper terminology for the Outlook "Thing" that opens up in excel (shown below)? Is it simply a toolbar? Add-in?
Second question, I have a excel file that automatically loads the outlook "Toolbar" each time it is opened.
The file was made in 2010 and password protected and locked, sent to a worker who edited the appropriate fields and saved, and then they sent the file back to me (2003 Format). Now this file automatically loads the outlook toolbar. I am trying to trouble shoot so what would cause this behavior?
View 4 Replies
View Related
Mar 5, 2012
I am running excel 2007 thin client. in attempting to refresh a query, I have encountered this error message: "run time error 1004 Incomplete datasource". The four line macro is as follows:
Code:
Sub RefreshFamily()
Sheets("Family").QueryTables("Family_refresh").EnableRefresh = True
Sheets("Family").QueryTables("Family_refresh").Refresh BackgroundQuery:=True
Sheets("Family").QueryTables("Family_refresh").EnableRefresh = False
End Sub
Where the named range "Family refresh" is defined as :
Code:
=OFFSET(Family!$A$1,0,0,COUNTA(Family!$A:$A),COUNTA(Family!$1:$1)-2)
Why the macro thinks that my named range does not exist?
View 1 Replies
View Related
Jul 16, 2014
The following script runs fine the first time I click the command button on an Access form but after I close the Excel workbook and click the command button again to edit a new spreadsheet, I get the follow error message:
Run-time error '1004': Method "Columns' of object'_Global failed.
It fails here:
Code:
Columns("H:H").Select
The script is being run from Access 2007 and is opening a spreadsheet in Excel 2007 (but using xls extension)
Code:
Private Sub IdahotoExcel_Click()
Dim dlg As FileDialog
Dim idahofile As String
[Code].....
View 5 Replies
View Related
Aug 21, 2014
I manage to find a macro online, which aims to insert a desired formula into desired cell range. However, when I execute the macro, i get a "run-time error, 1004".
View 1 Replies
View Related
May 9, 2008
This piece of code runs perfectly on its own but when called at the end of another code it fails and I haven't a clue why. The reference wsTmp is dim'd globally and defined in the main component where it is simply - worksheets("somename")
Run-time error '1004':
The sort reference is not valid. Make sure that it's within the data you want to sort, and the first Sort By box isn't the same or blank.
Private Sub FinalSort()
wsTmp.Cells.Sort Key1:=Range("D2"), Order1:=xlAscending, Key2:=Range("A2") _
, Order2:=xlAscending, Key3:=Range("K2"), Order3:=xlAscending, Header:= _
xlGuess, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal, DataOption2:=xlSortNormal, DataOption3:= _
xlSortNormal
End Sub
View 9 Replies
View Related
Mar 7, 2014
I have an excel workbook (Excel 2010) consisting on 30 sheets, I would like to add a command button to one (1) of the sheets that would attach just that sheet and not the whole workbook to my Outlook 2010 email, is this possible. What would the code look like.
View 1 Replies
View Related
Nov 29, 2012
I did this 10 years ago so I admit I am rusty at this but here are what I had in my notes that worked with Excel XP. I am currently using Excel 2010
With ThisWorkbook
.HasRoutingSlip = True
With .RoutingSlip
[Code]....
The last line will send the workbook but I need a Subject and Message to go with it.
View 9 Replies
View Related
Jun 20, 2013
1.) I have excel 2007 and when I recorded the macro yesterday it worked just fine, but today it's coming up with the box to update values. The macro is set to open up the vendor assignment sheet and do a vlookup against the clerk and then return the information to the original sheet and then copy paste special values. 2.) Today it's also doing the calculating thing in the corner using 2 processors which it has not done before. 3.) Run-time error '1004': PasteSpecial method of Range class failed.
[code]' Keyboard Shortcut: Ctrl+r
'
Dim OriginalSheet As Workbook
Set OriginalSheet = ActiveWorkbook
Columns("B:B").Cut
With Columns("A:A")
.Insert Shift:=xlToRight
End With
[code]....
View 2 Replies
View Related
Sep 26, 2013
My excel version is 2007 and i am on WIN7 64bit
I have a workbook with VBA which was working fine earlier. Lately i have been getting
"Runtime error 1004" Select method of button class failed.
I am adding buttons dynamically in a loop in a sheet and what surprise me is , i go to debug mode when error pops up and it points to below line
MySheet.Buttons.Add(ActiveCell.Left - 5, 25, 20).Select
but my code is running in a loop and i can see that atleast 20 buttons were added and it fails to select when it try to add this iteration. It is completely confusing me.
My entire below code is in a loop
Code:
maWrk.Cells(xIt1, yIt2).Select
mySheet.Buttons.Add(ActiveCell.Left - 5, 25, 20).Select
Selection.OnAction = "callMe"
[Code]....
I also notice that when it fails, on select method .. the button was actually added to the sheet with caption/name as "Button 65536" but then fails to select it. What makes the select to fail after adding the button? Could there be anything special with Button 65536?
Is there any better way to code the adding button and setting action and name for excel 2007?
note before entering the loop i am deleting all the shapes with myShape.Delete which name matches "btRun"
I also want to highlight that i don't have 65536 rows in my sheet. I just have 200 rows. and when this error happens it is on row 150 so firstly i wonder why it is naming the button as Button 65536. I would assume it will start with 1 and go on increments.
What makes excel to fail to select an added button in VBA?
View 6 Replies
View Related
May 17, 2014
I'm using Excel 2013 and I'm getting an issue in vba I can't figure out. (This is something I've done several dozen time before) But everytime I try to copy a sheet in a workbook,
Sheets("Sheet1").Copy After:=WB.Sheets(WB.Sheets.Count)
I recently copied in this sheet from another workbook, and deleted all of it's formula names, but I can't copy any other sheets now either.
The Run time Error 1004: Copy method of Worksheet Class failed pops up. What is weird is that I put in a msgbox and
MsgBox (WB.Sheets.Count)
returns a "1" though the sheet has about a dozen sheets within it. I've saved the workbook and even saved it as another name.
The sheet I imported has a sheet number of 77 while the previous last sheet was 23, could this be a cause?
View 2 Replies
View Related
Mar 26, 2014
I have the following code that allow me to select all of the cells with the color same as the active cell within a selected range:
Sub SelectCellColor()
Dim CellColorFormat As Long
Dim RangeString
[Code]....
I'd like to ask how can I fix the error so that there will not be a limit of the number of colored cells in a selected area?
View 2 Replies
View Related
Mar 11, 2014
I am trying to write a macro to send mail on every Friday and also on last day of every month. If the last day of the month falls on Saturday or Sunday then the macro should mail on Friday. I have written a separate macro to send a mail. I have also written to check day(ie Monday, Tuesday etc) of today. If today is Friday or month end i can send mail. I dont know how to tell the macro to send mail on friday if the month last date is saturday or sunday.
Sub done()
Dim Dat As Date, x As Integer, y As Date, sorry As String
Dim str As String
sorry = "Today is not friday or month end. So i cannot send mails"
str = WeekdayName(Weekday(Now()))
[Code] ........
View 1 Replies
View Related
May 9, 2007
I'm trying to find the last row on a sheet and then set the next cell, in column A to a certain value. It fails with Method 'Range' of object '_Worksheet' failed.
'activate the male page
sMalePicks.Activate
'add to last row of male baggage
lastRow = sMalePicks.Cells.Find(What:="*", _
SearchDirection:=xlPrevious, _
SearchOrder:=xlByRows).Row
'get next row
lastRow = lastRow + 1
sMalePicks.Range(Cells(lastRow, 1), Cells(lastRow, 1)) = Trim(bagNames(x))
View 5 Replies
View Related
Feb 5, 2014
Excel 2010. Windows 7
Run-time error '-2147467259 (80004005)':
An unexpected token ""20*"" was found following "1' AND
PERIOD = LIKE*. Expected tokens may include: "". SQLSTATE=42601
code died at RS.Open SQL, CN
/////////////////////////////////////////////////////////
Sub GET_OSI
Dim sn as String, osi as string, saposi As String
[code]....
View 2 Replies
View Related
Jun 19, 2007
i use Excel 2007.............
The SendMail Method took it from OzGrid web does not work with me . It gives me an error msg : Method send mail of object workbook failed...........
Do i have to refrence 2 particular library. i use OP windos vista (windows mail)
Sub SendActiveWorkbook()
On Error Rsume Next
ActiveWorkbook.SendMail _
Recipients:="dump@ozgrid.com", _
Subject:="Try Me " & Format( Date, "dd/mmm/yy")
On Error Goto 0
End Sub
View 7 Replies
View Related
Apr 24, 2014
I have a VBA excel file that pulls data from a CSV file downloaded from a link. I format this data into a table through excel and then copy it over to Outlook. This is where the problem is. I get a runtime error 4065 for "file is locked for editing".
View 1 Replies
View Related
Dec 1, 2011
I am writing macros for a pop up calender in excel 2010. I followed instructions in the link below but at the testing step # 7 it returned; 'run time eror 424 object required'. It's my first time writing macros.
[URL]
View 2 Replies
View Related
Mar 20, 2014
Im looking to create a reporting mechanism for a shared worksheet that im putting together.
I am looking to create some that will automatically create an email (either through outlook, or using a userform) and automatically populate with my email address in the 'To' section and automatically populate the subject with 'Error/Info Change'. The user can then populate the main email body with whatever they want to notify me of.
Im then hoping that the code can be run through a macro which has been added to the quick access toolbar.
View 2 Replies
View Related
Nov 15, 2013
Trying to be slick with my macro I have 2 sheets collecting data in a workbook. I am attempting to send as attachments only those 2 sheets. I am getting an error at the following space within the code. How do I get around this?
Code:
Sub Send_to_Me()
' Send_to_Me Macro
Dim objTemp As Object
Dim FileExt As String
Dim TempFileName As String
Dim FileFullPath As String
Dim FileFormat As Variant
[Code] ......
This is the line that I get with the message above. It is only 2 sheets. Excel 2010 Windows 2007
View 2 Replies
View Related
Jan 12, 2007
Is there a limit on the amout of pictures you can use with the statement me.pictures.visible? Reason being, I am trying to import 119 pictures into a spreadsheet. When the information is selected form a drop down list, it pulls up the 1 of the 119 pictures. I was able to get 54 pictures input. Everything was going great until the 55th. When it stared giving me an error...
______________________________________________
Runtime Error '1004':
Unable to set the Visible property of the Pictures class
______________________________________________
When I select Debug, it takes me to the line with Me.Pictures.Visible = False
Everything seems to work fine until I enter the 55th picture. If it is that, is there a viable work around?
View 9 Replies
View Related
Feb 22, 2007
Getting a error message when opening a workbook "Runtime error 1004" I dont know much about excel and the user explained it to me as best she could . Here is where the script bugs:
Sub auto_open()
fdist = ActiveWorkbook.Name
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Worksheets("f_cumul").Cells.ClearContents
Worksheets("f_cumul").Cells.ClearFormats
Worksheets("vtes_dj").Select
Range("a1").Select
Selection.End(xlDown).Select..............
View 9 Replies
View Related
Apr 21, 2014
When I run the following code it keeps giving me a runtime error 1004.
Code:
Sub ImportData()
Dim fNameAndPath As Variant
Dim wb As Workbook
Dim cNextRow As Long
Dim Ans As String
NextRow = ThisWorkbook.Worksheets("Errors").Range("B" & Rows.Count).End(xlUp).Row + 1
cNextRow = ThisWorkbook.Worksheets("Compare").Range("A" & Rows.Count).End(xlUp).Row + 1
[code]...
View 3 Replies
View Related
Feb 15, 2008
I have this macro and I keep getting a 1004 runtime error 'PasteSpecial method of range class failed' on the highlighted line,
Sub Print_()
'
Sheets("Sheet1").Select
Cells.Select
Selection.Copy
Sheets("Print").Select
Cells.Select
Selection.PasteSpecial Paste:=xlPasteColumnWidths, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
With Selection.Interior
.ColorIndex = 2
.PatternColorIndex = xlAutomatic
End With
View 9 Replies
View Related
May 21, 2014
How to modify the below vba code? It sends an email with an attachment right away after pressing the macro button. I would like the user to see the email in outlook before it gets send... and then press 'send' in Outlook .....
Sub Mail_ActiveSheet()
'Working in Excel 2000-2013
'For Tips see: http://www.rondebruin.nl/win/winmail/Outlook/tips.htm
Dim FileExtStr As String
Dim FileFormatNum As Long
[Code] .....
View 1 Replies
View Related