Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 43
Default wb.savecopyas results in read only copy

I setup a macro that would allow a user to send a copy of the entire workbook
to me should it malfunction so I can try to duplicate their problem. The
code works great to save a copy, send it via CDO, then delete the copy, but
when I try to open the copy, it is read only. I checked the properties of
the document, and unbocked it, it's still read only, the read only box was
not checked in the properties either. I cannot open the file at all. Here's
the code:
'Sub Email()
Dim iMsg As Object
Dim iConf As Object
Dim Cell As Range
Dim Reply As String
Dim wb As Workbook
Dim WBname As String
' Dim Flds As Variant

' Set iConf = CreateObject("CDO.Configuration")
' iConf.Load -1 ' CDO Source Defaults
' Set Flds = iConf.Fields
' With Flds
'
..Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
'
..Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") =
"smtp.myservername.com" 'I input actual
'
..Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
' .Update
' End With
Application.ScreenUpdating = False
Set wb = ActiveWorkbook
Reply = MsgBox("Are you sure you want to send this error file?" & Chr(10),
vbYesNo)
If Reply = vbYes Then
WBname = wb.Name & " " & Format(Now, "mm-dd-yy h-mm") & ".xls"
wb.SaveCopyAs "C:/" & WBname
Set iMsg = CreateObject("CDO.Message")
With iMsg
Set .Configuration = iConf
.To = """Mike"" " 'I input actual, to
me & from me
.CC = ""
.BCC = ""
.Subject = "ERROR FILE from " & Sheets("Setup").Range("H6")
'identifies the username
.From = """ERROR FILE"" " 'I input
actual, to me & from me
' Set importance or Priority to high
.Fields("urn:schemas:httpmail:importance") = 2
.Fields("urn:schemas:mailheader:X-Priority") = 1
' Update fields
.Fields.Update
.AddAttachment "C:/" & WBname
.Send
Kill "C:/" & WBname
Set iMsg = Nothing
Set iConf = Nothing
Set wb = Nothing
Application.ScreenUpdating = True
End With
End If
End Sub
'
Any help is appreciated!

Mike
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default wb.savecopyas results in read only copy

Hi Mike

From my site

Don't remove the TextBody line in the code. If you do you can't open the attachment (bug in CDO).
If you don't want to have text in the body use this then .TextBody = ""


--

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


"mikeolson" wrote in message ...
I setup a macro that would allow a user to send a copy of the entire workbook
to me should it malfunction so I can try to duplicate their problem. The
code works great to save a copy, send it via CDO, then delete the copy, but
when I try to open the copy, it is read only. I checked the properties of
the document, and unbocked it, it's still read only, the read only box was
not checked in the properties either. I cannot open the file at all. Here's
the code:
'Sub Email()
Dim iMsg As Object
Dim iConf As Object
Dim Cell As Range
Dim Reply As String
Dim wb As Workbook
Dim WBname As String
' Dim Flds As Variant

' Set iConf = CreateObject("CDO.Configuration")
' iConf.Load -1 ' CDO Source Defaults
' Set Flds = iConf.Fields
' With Flds
'
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
'
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") =
"smtp.myservername.com" 'I input actual
'
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
' .Update
' End With
Application.ScreenUpdating = False
Set wb = ActiveWorkbook
Reply = MsgBox("Are you sure you want to send this error file?" & Chr(10),
vbYesNo)
If Reply = vbYes Then
WBname = wb.Name & " " & Format(Now, "mm-dd-yy h-mm") & ".xls"
wb.SaveCopyAs "C:/" & WBname
Set iMsg = CreateObject("CDO.Message")
With iMsg
Set .Configuration = iConf
.To = """Mike"" " 'I input actual, to
me & from me
.CC = ""
.BCC = ""
.Subject = "ERROR FILE from " & Sheets("Setup").Range("H6")
'identifies the username
.From = """ERROR FILE"" " 'I input
actual, to me & from me
' Set importance or Priority to high
.Fields("urn:schemas:httpmail:importance") = 2
.Fields("urn:schemas:mailheader:X-Priority") = 1
' Update fields
.Fields.Update
.AddAttachment "C:/" & WBname
.Send
Kill "C:/" & WBname
Set iMsg = Nothing
Set iConf = Nothing
Set wb = Nothing
Application.ScreenUpdating = True
End With
End If
End Sub
'
Any help is appreciated!

Mike

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 43
Default wb.savecopyas results in read only copy

Thanks Ron! Works perfect now!

Mike

"Ron de Bruin" wrote:

Hi Mike

From my site

Don't remove the TextBody line in the code. If you do you can't open the attachment (bug in CDO).
If you don't want to have text in the body use this then .TextBody = ""


--

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


"mikeolson" wrote in message ...
I setup a macro that would allow a user to send a copy of the entire workbook
to me should it malfunction so I can try to duplicate their problem. The
code works great to save a copy, send it via CDO, then delete the copy, but
when I try to open the copy, it is read only. I checked the properties of
the document, and unbocked it, it's still read only, the read only box was
not checked in the properties either. I cannot open the file at all. Here's
the code:
'Sub Email()
Dim iMsg As Object
Dim iConf As Object
Dim Cell As Range
Dim Reply As String
Dim wb As Workbook
Dim WBname As String
' Dim Flds As Variant

' Set iConf = CreateObject("CDO.Configuration")
' iConf.Load -1 ' CDO Source Defaults
' Set Flds = iConf.Fields
' With Flds
'
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
'
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") =
"smtp.myservername.com" 'I input actual
'
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
' .Update
' End With
Application.ScreenUpdating = False
Set wb = ActiveWorkbook
Reply = MsgBox("Are you sure you want to send this error file?" & Chr(10),
vbYesNo)
If Reply = vbYes Then
WBname = wb.Name & " " & Format(Now, "mm-dd-yy h-mm") & ".xls"
wb.SaveCopyAs "C:/" & WBname
Set iMsg = CreateObject("CDO.Message")
With iMsg
Set .Configuration = iConf
.To = """Mike"" " 'I input actual, to
me & from me
.CC = ""
.BCC = ""
.Subject = "ERROR FILE from " & Sheets("Setup").Range("H6")
'identifies the username
.From = """ERROR FILE"" " 'I input
actual, to me & from me
' Set importance or Priority to high
.Fields("urn:schemas:httpmail:importance") = 2
.Fields("urn:schemas:mailheader:X-Priority") = 1
' Update fields
.Fields.Update
.AddAttachment "C:/" & WBname
.Send
Kill "C:/" & WBname
Set iMsg = Nothing
Set iConf = Nothing
Set wb = Nothing
Application.ScreenUpdating = True
End With
End If
End Sub
'
Any help is appreciated!

Mike


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
Hiding Results when result should read blank Looking for help today[_2_] Excel Worksheet Functions 1 March 25th 09 09:36 PM
I copy a formula and the results copy from the original cell brooklynsd Excel Discussion (Misc queries) 1 June 23rd 07 01:35 AM
Open a read-only copy grok Excel Discussion (Misc queries) 2 October 25th 06 08:04 PM
Excel VBA - read a WS and show results on another belblanco[_5_] Excel Programming 1 July 9th 04 08:22 PM
SaveCopyAs Mark Worthington Excel Programming 4 February 8th 04 06:00 AM


All times are GMT +1. The time now is 04:48 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"