Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 29
Default Problem with macro to email xls

Hi, I've been using a macro to automatically send Excel worksheets to
specific email addresses on quite a few files I have set up. I just added
this macro to a spreadsheet that has some merged cells that are used for
notes. I realized after I began using the macro that any text typed into the
merged cell beyond 250 characters is deleted when the worksheet is emailed
using the macro. I don't believe this is a problem with the code, but I am
including it below to make sure. Is there any work around for this?

Sub Mail_ActiveSheet_PR()
Dim wb As Workbook
Dim strdate As String
strdate = Format(Now, "yymmdd")
Application.ScreenUpdating = False
ActiveSheet.Copy
Set wb = ActiveWorkbook
With wb
.SaveAs "C:\" & Sheets("Dom. Parts Order Req").Range("D11").Value &
" Approved.xls"
.SendMail ", Sheets("Dom. Parts Order
Req").Range("D11").Value
.ChangeFileAccess xlReadOnly
Kill .FullName
.Close False
End With
Application.ScreenUpdating = True
End Sub

Thanks,
Holly
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,123
Default Problem with macro to email xls

The only thing you can do to avoid this Excel bug (btw: fixed in excel 2007) is to
to add a new workbook with one sheet and copy all cells from your sheet in this workbook

Sub Mail_ActiveSheet_PR()
Dim ws As Worksheet
Dim wb As Workbook
Dim strdate As String
strdate = Format(Now, "yymmdd")

Application.ScreenUpdating = False

Set ws = ActiveSheet
Set wb = Workbooks.Add(1)
ws.Cells.Copy wb.Sheets(1).Cells(1)
ws.Name = "Dom. Parts Order Req"

With wb
.SaveAs "C:\" & wb.Sheets(1).Range("D11").Value & " Approved.xls"
.SendMail ", wb.Sheets(1).Range("D11").Value
.ChangeFileAccess xlReadOnly
Kill .FullName
.Close False
End With
Application.ScreenUpdating = True
End Sub



--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"hnyb1" wrote in message ...
Hi, I've been using a macro to automatically send Excel worksheets to
specific email addresses on quite a few files I have set up. I just added
this macro to a spreadsheet that has some merged cells that are used for
notes. I realized after I began using the macro that any text typed into the
merged cell beyond 250 characters is deleted when the worksheet is emailed
using the macro. I don't believe this is a problem with the code, but I am
including it below to make sure. Is there any work around for this?

Sub Mail_ActiveSheet_PR()
Dim wb As Workbook
Dim strdate As String
strdate = Format(Now, "yymmdd")
Application.ScreenUpdating = False
ActiveSheet.Copy
Set wb = ActiveWorkbook
With wb
.SaveAs "C:\" & Sheets("Dom. Parts Order Req").Range("D11").Value &
" Approved.xls"
.SendMail ", Sheets("Dom. Parts Order
Req").Range("D11").Value
.ChangeFileAccess xlReadOnly
Kill .FullName
.Close False
End With
Application.ScreenUpdating = True
End Sub

Thanks,
Holly

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 29
Default Problem with macro to email xls

Thanks, Ron.

This worked perfectly. One more question, though. Anyway this can be made
to work on emailing 2 worksheets in a workbook?

Thanks again,
Holly

"Ron de Bruin" wrote:

The only thing you can do to avoid this Excel bug (btw: fixed in excel 2007) is to
to add a new workbook with one sheet and copy all cells from your sheet in this workbook

Sub Mail_ActiveSheet_PR()
Dim ws As Worksheet
Dim wb As Workbook
Dim strdate As String
strdate = Format(Now, "yymmdd")

Application.ScreenUpdating = False

Set ws = ActiveSheet
Set wb = Workbooks.Add(1)
ws.Cells.Copy wb.Sheets(1).Cells(1)
ws.Name = "Dom. Parts Order Req"

With wb
.SaveAs "C:\" & wb.Sheets(1).Range("D11").Value & " Approved.xls"
.SendMail ", wb.Sheets(1).Range("D11").Value
.ChangeFileAccess xlReadOnly
Kill .FullName
.Close False
End With
Application.ScreenUpdating = True
End Sub



--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"hnyb1" wrote in message ...
Hi, I've been using a macro to automatically send Excel worksheets to
specific email addresses on quite a few files I have set up. I just added
this macro to a spreadsheet that has some merged cells that are used for
notes. I realized after I began using the macro that any text typed into the
merged cell beyond 250 characters is deleted when the worksheet is emailed
using the macro. I don't believe this is a problem with the code, but I am
including it below to make sure. Is there any work around for this?

Sub Mail_ActiveSheet_PR()
Dim wb As Workbook
Dim strdate As String
strdate = Format(Now, "yymmdd")
Application.ScreenUpdating = False
ActiveSheet.Copy
Set wb = ActiveWorkbook
With wb
.SaveAs "C:\" & Sheets("Dom. Parts Order Req").Range("D11").Value &
" Approved.xls"
.SendMail ", Sheets("Dom. Parts Order
Req").Range("D11").Value
.ChangeFileAccess xlReadOnly
Kill .FullName
.Close False
End With
Application.ScreenUpdating = True
End Sub

Thanks,
Holly


  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,123
Default Problem with macro to email xls

Try this one for "sheet1" and "sheet3"

Sub Mail_ActiveSheet_PR()
Dim i As Integer
Dim sh As Worksheet
Dim wb1 As Workbook
Dim wb As Workbook
Dim strdate As String
strdate = Format(Now, "yymmdd")

Application.ScreenUpdating = False

Set wb1 = ThisWorkbook
Set wb = Workbooks.Add(1)
wb.Worksheets.Add after:=wb.Sheets(1)

i = 0

For Each sh In wb1.Sheets(Array("Sheet1", "Sheet3"))
i = i + 1
sh.Cells.Copy wb.Sheets(i).Cells(1)
Next sh

With wb
.SaveAs "C:\" & wb.Sheets(1).Range("D11").Value & " Approved.xls"
.SendMail ", wb.Sheets(1).Range("D11").Value
.ChangeFileAccess xlReadOnly
Kill .FullName
.Close False
End With
Application.ScreenUpdating = True
End Sub



--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"hnyb1" wrote in message ...
Thanks, Ron.

This worked perfectly. One more question, though. Anyway this can be made
to work on emailing 2 worksheets in a workbook?

Thanks again,
Holly

"Ron de Bruin" wrote:

The only thing you can do to avoid this Excel bug (btw: fixed in excel 2007) is to
to add a new workbook with one sheet and copy all cells from your sheet in this workbook

Sub Mail_ActiveSheet_PR()
Dim ws As Worksheet
Dim wb As Workbook
Dim strdate As String
strdate = Format(Now, "yymmdd")

Application.ScreenUpdating = False

Set ws = ActiveSheet
Set wb = Workbooks.Add(1)
ws.Cells.Copy wb.Sheets(1).Cells(1)
ws.Name = "Dom. Parts Order Req"

With wb
.SaveAs "C:\" & wb.Sheets(1).Range("D11").Value & " Approved.xls"
.SendMail ", wb.Sheets(1).Range("D11").Value
.ChangeFileAccess xlReadOnly
Kill .FullName
.Close False
End With
Application.ScreenUpdating = True
End Sub



--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"hnyb1" wrote in message ...
Hi, I've been using a macro to automatically send Excel worksheets to
specific email addresses on quite a few files I have set up. I just added
this macro to a spreadsheet that has some merged cells that are used for
notes. I realized after I began using the macro that any text typed into the
merged cell beyond 250 characters is deleted when the worksheet is emailed
using the macro. I don't believe this is a problem with the code, but I am
including it below to make sure. Is there any work around for this?

Sub Mail_ActiveSheet_PR()
Dim wb As Workbook
Dim strdate As String
strdate = Format(Now, "yymmdd")
Application.ScreenUpdating = False
ActiveSheet.Copy
Set wb = ActiveWorkbook
With wb
.SaveAs "C:\" & Sheets("Dom. Parts Order Req").Range("D11").Value &
" Approved.xls"
.SendMail ", Sheets("Dom. Parts Order
Req").Range("D11").Value
.ChangeFileAccess xlReadOnly
Kill .FullName
.Close False
End With
Application.ScreenUpdating = True
End Sub

Thanks,
Holly


  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,123
Default Problem with macro to email xls

This one is easier and also have the correct sheet names

Sub Mail_ActiveSheet_PR()
Dim sh As Worksheet
Dim wb1 As Workbook
Dim wb2 As Workbook
Dim strdate As String
strdate = Format(Now, "yymmdd")

Application.ScreenUpdating = False

Set wb1 = ThisWorkbook

wb1.Sheets(Array("Sheet1", "Sheet3")).Copy
Set wb2 = ActiveWorkbook

For Each sh In wb2.Worksheets
wb1.Sheets(sh.Name).Cells.Copy wb2.Sheets(sh.Name).Cells(1)
Next sh

With wb2
.SaveAs "C:\" & wb2.Sheets(1).Range("D11").Value & " Approved.xls"
.SendMail ", wb2.Sheets(1).Range("D11").Value
.ChangeFileAccess xlReadOnly
Kill .FullName
.Close False
End With
Application.ScreenUpdating = True
End Sub



--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Ron de Bruin" wrote in message ...
Try this one for "sheet1" and "sheet3"

Sub Mail_ActiveSheet_PR()
Dim i As Integer
Dim sh As Worksheet
Dim wb1 As Workbook
Dim wb As Workbook
Dim strdate As String
strdate = Format(Now, "yymmdd")

Application.ScreenUpdating = False

Set wb1 = ThisWorkbook
Set wb = Workbooks.Add(1)
wb.Worksheets.Add after:=wb.Sheets(1)

i = 0

For Each sh In wb1.Sheets(Array("Sheet1", "Sheet3"))
i = i + 1
sh.Cells.Copy wb.Sheets(i).Cells(1)
Next sh

With wb
.SaveAs "C:\" & wb.Sheets(1).Range("D11").Value & " Approved.xls"
.SendMail ", wb.Sheets(1).Range("D11").Value
.ChangeFileAccess xlReadOnly
Kill .FullName
.Close False
End With
Application.ScreenUpdating = True
End Sub



--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"hnyb1" wrote in message ...
Thanks, Ron.

This worked perfectly. One more question, though. Anyway this can be made
to work on emailing 2 worksheets in a workbook?

Thanks again,
Holly

"Ron de Bruin" wrote:

The only thing you can do to avoid this Excel bug (btw: fixed in excel 2007) is to
to add a new workbook with one sheet and copy all cells from your sheet in this workbook

Sub Mail_ActiveSheet_PR()
Dim ws As Worksheet
Dim wb As Workbook
Dim strdate As String
strdate = Format(Now, "yymmdd")

Application.ScreenUpdating = False

Set ws = ActiveSheet
Set wb = Workbooks.Add(1)
ws.Cells.Copy wb.Sheets(1).Cells(1)
ws.Name = "Dom. Parts Order Req"

With wb
.SaveAs "C:\" & wb.Sheets(1).Range("D11").Value & " Approved.xls"
.SendMail ", wb.Sheets(1).Range("D11").Value
.ChangeFileAccess xlReadOnly
Kill .FullName
.Close False
End With
Application.ScreenUpdating = True
End Sub



--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"hnyb1" wrote in message ...
Hi, I've been using a macro to automatically send Excel worksheets to
specific email addresses on quite a few files I have set up. I just added
this macro to a spreadsheet that has some merged cells that are used for
notes. I realized after I began using the macro that any text typed into the
merged cell beyond 250 characters is deleted when the worksheet is emailed
using the macro. I don't believe this is a problem with the code, but I am
including it below to make sure. Is there any work around for this?

Sub Mail_ActiveSheet_PR()
Dim wb As Workbook
Dim strdate As String
strdate = Format(Now, "yymmdd")
Application.ScreenUpdating = False
ActiveSheet.Copy
Set wb = ActiveWorkbook
With wb
.SaveAs "C:\" & Sheets("Dom. Parts Order Req").Range("D11").Value &
" Approved.xls"
.SendMail ", Sheets("Dom. Parts Order
Req").Range("D11").Value
.ChangeFileAccess xlReadOnly
Kill .FullName
.Close False
End With
Application.ScreenUpdating = True
End Sub

Thanks,
Holly



  #6   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 29
Default Problem with macro to email xls

Thank you so much! This is excellent.

"Ron de Bruin" wrote:

This one is easier and also have the correct sheet names

Sub Mail_ActiveSheet_PR()
Dim sh As Worksheet
Dim wb1 As Workbook
Dim wb2 As Workbook
Dim strdate As String
strdate = Format(Now, "yymmdd")

Application.ScreenUpdating = False

Set wb1 = ThisWorkbook

wb1.Sheets(Array("Sheet1", "Sheet3")).Copy
Set wb2 = ActiveWorkbook

For Each sh In wb2.Worksheets
wb1.Sheets(sh.Name).Cells.Copy wb2.Sheets(sh.Name).Cells(1)
Next sh

With wb2
.SaveAs "C:\" & wb2.Sheets(1).Range("D11").Value & " Approved.xls"
.SendMail ", wb2.Sheets(1).Range("D11").Value
.ChangeFileAccess xlReadOnly
Kill .FullName
.Close False
End With
Application.ScreenUpdating = True
End Sub



--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Ron de Bruin" wrote in message ...
Try this one for "sheet1" and "sheet3"

Sub Mail_ActiveSheet_PR()
Dim i As Integer
Dim sh As Worksheet
Dim wb1 As Workbook
Dim wb As Workbook
Dim strdate As String
strdate = Format(Now, "yymmdd")

Application.ScreenUpdating = False

Set wb1 = ThisWorkbook
Set wb = Workbooks.Add(1)
wb.Worksheets.Add after:=wb.Sheets(1)

i = 0

For Each sh In wb1.Sheets(Array("Sheet1", "Sheet3"))
i = i + 1
sh.Cells.Copy wb.Sheets(i).Cells(1)
Next sh

With wb
.SaveAs "C:\" & wb.Sheets(1).Range("D11").Value & " Approved.xls"
.SendMail ", wb.Sheets(1).Range("D11").Value
.ChangeFileAccess xlReadOnly
Kill .FullName
.Close False
End With
Application.ScreenUpdating = True
End Sub



--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"hnyb1" wrote in message ...
Thanks, Ron.

This worked perfectly. One more question, though. Anyway this can be made
to work on emailing 2 worksheets in a workbook?

Thanks again,
Holly

"Ron de Bruin" wrote:

The only thing you can do to avoid this Excel bug (btw: fixed in excel 2007) is to
to add a new workbook with one sheet and copy all cells from your sheet in this workbook

Sub Mail_ActiveSheet_PR()
Dim ws As Worksheet
Dim wb As Workbook
Dim strdate As String
strdate = Format(Now, "yymmdd")

Application.ScreenUpdating = False

Set ws = ActiveSheet
Set wb = Workbooks.Add(1)
ws.Cells.Copy wb.Sheets(1).Cells(1)
ws.Name = "Dom. Parts Order Req"

With wb
.SaveAs "C:\" & wb.Sheets(1).Range("D11").Value & " Approved.xls"
.SendMail ", wb.Sheets(1).Range("D11").Value
.ChangeFileAccess xlReadOnly
Kill .FullName
.Close False
End With
Application.ScreenUpdating = True
End Sub



--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"hnyb1" wrote in message ...
Hi, I've been using a macro to automatically send Excel worksheets to
specific email addresses on quite a few files I have set up. I just added
this macro to a spreadsheet that has some merged cells that are used for
notes. I realized after I began using the macro that any text typed into the
merged cell beyond 250 characters is deleted when the worksheet is emailed
using the macro. I don't believe this is a problem with the code, but I am
including it below to make sure. Is there any work around for this?

Sub Mail_ActiveSheet_PR()
Dim wb As Workbook
Dim strdate As String
strdate = Format(Now, "yymmdd")
Application.ScreenUpdating = False
ActiveSheet.Copy
Set wb = ActiveWorkbook
With wb
.SaveAs "C:\" & Sheets("Dom. Parts Order Req").Range("D11").Value &
" Approved.xls"
.SendMail ", Sheets("Dom. Parts Order
Req").Range("D11").Value
.ChangeFileAccess xlReadOnly
Kill .FullName
.Close False
End With
Application.ScreenUpdating = True
End Sub

Thanks,
Holly


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
macro to email Scott Marcus Excel Discussion (Misc queries) 1 June 21st 06 03:04 PM
Email and Excel Problem carl Excel Worksheet Functions 2 May 22nd 06 08:45 PM
How do I email an excel macro? Bruce Excel Discussion (Misc queries) 7 January 20th 06 11:34 PM
Problem opening excel files from email DXC001 Excel Discussion (Misc queries) 1 October 3rd 05 07:56 PM
Macro To Email XLS ynissel Excel Discussion (Misc queries) 4 May 26th 05 07:12 PM


All times are GMT +1. The time now is 12:40 PM.

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

About Us

"It's about Microsoft Excel"