cbaldan
06-08-2011, 08:27 AM
Hello.
I have a spreadsheet that has the summary of some projects, and is password protect. At the end of the day, I need to people to send it over by e-mail.
I want to have a macro that will unprotect, copy the contents of the spreadsheet, paste Special into a new Outook e-mail as Enhanced Windows Metafile, and reprotect the spreadsheet. So far I found a workaround using a msgbox, but the users still need to make a manual Paste Special.
My issue is that I could not find a way to use the PasteSpecial method alogn the HTMLBody.
Any help is appreciated.
Thanks, Cleber.
Sub copyToClipboard()
Sheets(1).Unprotect Password:="123"
Set myOlApp = CreateObject("Outlook.Application")
Set emailInforme = myOlApp.CreateItem(olMailItem)
emailInforme.Subject = "Informe Diário do Projeto: " & Range("D6").Value & " - " & Range("D7").Value
Cells.Find(What:="##FIM", After:=ActiveCell, LookIn:=xlFormulas, LookAt :=xlPart, SearchOrder:=xlByRows, _
SearchDirection:=xlNext, MatchCase:= False, SearchFormat:=False).Activate
ActiveCell.Offset(1, 1).Select
Range("A1", ActiveCell).Select
Selection.Copy
emailInforme.Display
' emailInforme.HTMLBody.PasteSpecial (DataFormat = ppPasteEnhancedMetafile)
' The above line doesn't work
MsgBox "Click OK after sending the e-mail"
Range("B2").Select
Range("B2").Value = ""
Sheets(1).Protect Password:="123"
End Sub
I have a spreadsheet that has the summary of some projects, and is password protect. At the end of the day, I need to people to send it over by e-mail.
I want to have a macro that will unprotect, copy the contents of the spreadsheet, paste Special into a new Outook e-mail as Enhanced Windows Metafile, and reprotect the spreadsheet. So far I found a workaround using a msgbox, but the users still need to make a manual Paste Special.
My issue is that I could not find a way to use the PasteSpecial method alogn the HTMLBody.
Any help is appreciated.
Thanks, Cleber.
Sub copyToClipboard()
Sheets(1).Unprotect Password:="123"
Set myOlApp = CreateObject("Outlook.Application")
Set emailInforme = myOlApp.CreateItem(olMailItem)
emailInforme.Subject = "Informe Diário do Projeto: " & Range("D6").Value & " - " & Range("D7").Value
Cells.Find(What:="##FIM", After:=ActiveCell, LookIn:=xlFormulas, LookAt :=xlPart, SearchOrder:=xlByRows, _
SearchDirection:=xlNext, MatchCase:= False, SearchFormat:=False).Activate
ActiveCell.Offset(1, 1).Select
Range("A1", ActiveCell).Select
Selection.Copy
emailInforme.Display
' emailInforme.HTMLBody.PasteSpecial (DataFormat = ppPasteEnhancedMetafile)
' The above line doesn't work
MsgBox "Click OK after sending the e-mail"
Range("B2").Select
Range("B2").Value = ""
Sheets(1).Protect Password:="123"
End Sub