copier une plage dans outlook

C@thy

XLDnaute Barbatruc
Bonjour le forum,:cool:

j'ai cherché les fils correspondant au sujet, mais je ne trouve pas ce que je cherche.

Je dois copier une plage excel et la coller dans outlook, mais collage spécial en tant que image métafichier améliorée, en effet, le mail doit pouvoir être lu depuis un smartphone (traduction de mûre, pour ne pas le nommer...), et seule l'image métafichier améliorée convient...

je joins mon fichier exemple (et mes élucubrations macro) si ça peut aider.

Un grand merci à tous ceux qui pourraient tenter de répondre à ce sujet.

Bizz

C@thy
 

Pièces jointes

  • archivage de taux 2013 test envoi outlook.xlsm
    52.7 KB · Affichages: 68

C@thy

XLDnaute Barbatruc
Re : copier une plage dans outlook

Arf! J'ai comme l'impression que ce n'est pas possible!:mad:

Trois jours que je suis sur ce problème et je n'y arrive vraiment pas!:(

Impossible? Vous avez dit impossible? et pourtant... il semblerait bien!

Bises

C@thy
 

job75

XLDnaute Barbatruc
Re : copier une plage dans outlook

Bonjour C@thy,

Je pense que tu sais, dans Excel, créer une image de la plage (touche Maj enfoncée).

Tu la copies, puis tu vas sur ton message Outlook et (classiquement) touches Ctrl+V.

Pas difficile à faire par macro, sauf que sur Excel 2010 l'envoi de touches désactive le pavé numérique :mad:

Et pas certain que l'image passera sur les smartphones...

A+
 

job75

XLDnaute Barbatruc
Re : copier une plage dans outlook

Re C@thy, salut Zon,

Ce qui est important à savoir c'est si le message Outlook passe avec l'image sur les smartphones.

Donne-moi le résultat, je n'utilise pas Outlook.

Si non inutile de continuer.

Si oui la macro devrait se faire, avec ou sans SendKeys.

Edit : demain je serai absent toute la journée.

A+
 
Dernière édition:

C@thy

XLDnaute Barbatruc
Re : copier une plage dans outlook

Quel réel plaisir de vous voir ici tous les deux!
Vous savez combien je vous apprécie et le mot est faible.

Oui les smartbouzins (hihi) lisent les pdf, excellente idée mais
comme mes utilisateurs sont extrêmement exigeants je ne suis pas sûre
qu'ils veulent une pièce jointe... Ils ont demandé dans le corps du message...

Arf! Je l'ai toujours dit, l'application idéale c'est celle qui n'a pas d'utilisateurs.

Oui, Zon je suis sous 2010

Un grand MERCI a vous deux

Zoubis

C@thy
 

Staple1600

XLDnaute Barbatruc
Re : copier une plage dans outlook

Bonjour à tous

Une piste glanée sur le web anglophone.
(Je te laisse tester car pas d'outlook sur le pc que j'utilise ici)
Code vba:
Sub A_tester()
psSendEmailPictures "toto@toto.fr", "cathy@cathy.fr", "Objet:Envoyer Range en Image", ActiveSheet.Range("A1:C10")
End Sub





Code vba:
Sub psSendEmailPictures(strTo As String, strSentFrom As String, strSubject As String, rPictureAddress As Range)

'Created by David Thorn, December 2011
'Uses Outlook Object Model to send Excel range as picture in email

Dim Row As Integer
Dim StrFileName As String
Dim Outlook As Object
Dim OutlookMsg As Object
Dim SigString As String
Dim Signature As Variant
Dim oCht As Chart
Dim iSCount As Integer

'Turn off display alerts and screen updating
Application.DisplayAlerts = False
Application.ScreenUpdating = False

'Set the outlook object to the outlook application
Set Outlook = GetOutlookApp
'Create an email
Set OutlookMsg = Outlook.CreateItem(olMailItem)

'Create a chart
Set oCht = Charts.Add

'Ensure that the chart has no active series and is blank
For iSCount = 1 To ActiveChart.SeriesCollection.Count
ActiveChart.SeriesCollection(1).Delete
Next iSCount

'Copy the passed range as a picture
rPictureAddress.CopyPicture xlScreen, xlPicture

'Change chart location to the passed range worksheet
oCht.Location xlLocationAsObject, rPictureAddress.Worksheet.Name

'Set the chart to be height and width required on email
ActiveChart.ChartArea.Height = 618.8031496063
ActiveChart.ChartArea.Width = 479.3385826772

'Ensure that the chart area has no visible line
ActiveChart.ChartArea.Format.Line.Visible = msoFalse
'Paste the passed range into the chart
ActiveChart.Paste

'Export the chart with file name as current date and time
StrFileName = Format(Now(), "yymmddhhmmss")
ActiveChart.Export "C:\Documents and Settings\" & StrFileName & ".png", "png"

'Once the chart has been exported and saved delete the chart from the passed worksheet name
ActiveChart.Parent.Delete


'With the active outlook message update the send to address with the passed details
OutlookMsg.To = strTo

'If there is a sent from address present then add the details to the sent on behalf of name
If Len(strSentFrom) > 0 Then OutlookMsg.SentOnBehalfOfName = strSentFrom

OutlookMsg.Subject = strSubject

'Add the Export chart as an attachment
OutlookMsg.Attachments.Add ("C:\Documents and Settings\" & StrFileName & ".png")
'In the body of the email use html to reference the Exported chart, this is so the chart doesnt need to exsit on the recepients computer
OutlookMsg.HTMLBody = "<img src ='cid:" & StrFileName & ".png' />"

'Send the email
OutlookMsg.Send

'Set the dispaly and screen updating alerts back to true
Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub
 

C@thy

XLDnaute Barbatruc
Re : copier une plage dans outlook

Merci l'agrafe, peux pas tester maintenant car pas de PC le weekend-end
(sinon j'y passe mes nuits).

Dès lundi je teste et je te dis.

C'est quand même incroyable qu'on ne puisse pas faire un simple copier/coller dans Outlook en VBA!

Bizz

C@thy
 

Staple1600

XLDnaute Barbatruc
Re : copier une plage dans outlook

Re


Comme le dit Chip Pearson (et sauf erreur de ma part), on peut pas utiliser le clipboard en vba pour récupérer les images qui s'y trouvent.
(Ce que mes recherches infructueuses sur le net semblent confirmer)
Accessing The Windows Clipboard

The MSForms library contains an object called the DataObject that provides support for working with text strings on the Windows clipboard. VBA does not support the data type required for other, non-text, values on the clipboard. To use the DataObject in your code, you must set a reference to the Microsoft Forms 2.0 Object Library.

EDITION: Salut job75 ;)
 
Dernière édition:

job75

XLDnaute Barbatruc
Re : copier une plage dans outlook

Bonjour C@thy, Zon, salut Jean-Marie :)

C@thy essaie cette macro qui utilise SendKeys :

Code:
Sub EnvoiMail()
'Cocher la référence Microsoft Outlook xx.x Object Library
Dim OutApp As Object, OutMail As Object
[Aimprimer].CopyPicture xlScreen, xlPicture
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
With OutMail
  .To = "catherine.bancillon@finances.gouv.fr"
  .CC = ""
  .BCC = ""
  .Subject = "Solde consolidé à la Bdf au " & Format(Now, "dd mmmm yyyy")
  .HTMLBody = ""
  .Display
End With
SendKeys "^v" 'collage de l'image uniquement, pour voir
'SendKeys "^v%v" 'collage + envoi du message sur Outlook 2003
End Sub
Elle a l'air de fonctionner chez moi sur Office 2003.

Sur Outlook 2003 l'envoi d'un message se fait par Alt + v, je ne sais pas pour 2010.

Fichier joint.

A+
 

Pièces jointes

  • Message Outlook(1).xls
    69.5 KB · Affichages: 70

job75

XLDnaute Barbatruc
Re : copier une plage dans outlook

Re,

Je viens d'ouvrir un message sur mon iphone (Samsung).

L'image de la plage est bien là mais elle est tronquée à la ligne 24.

Il y a peut-être une limitation du nombre de lignes :confused:

Je ne suis pas du tout spécialiste des smartphones :cool:

A+
 

job75

XLDnaute Barbatruc
Re : copier une plage dans outlook

Re,

Une solution sans envoi de touches qui fonctionne bien sur Office 2003 :

Code:
Sub EnvoiMail()
'Cocher la référence Microsoft Outlook xx.x Object Library
'Cocher la référence Microsoft Word xx.x Object Library
Dim OutApp As Object, OutMail As Object
[Aimprimer].CopyPicture xlScreen, xlPicture
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
With OutMail
  .To = "catherine.bancillon@finances.gouv.fr"
  .CC = ""
  .BCC = ""
  .Subject = "Solde consolidé à la Bdf au " & Format(Now, "dd mmmm yyyy")
  .HTMLBody = ""
  .Display
  ActiveDocument.ActiveWindow.Selection.Paste 'colle l'image
  On Error Resume Next
  '.Send 'activer pour envoyer
End With
End Sub
Ne pas oublier de cocher les 2 références VBA.

A voir pour Office 2010.

Fichier joint.

A+
 

Pièces jointes

  • Message Outlook sans SendKeys(1).xls
    71.5 KB · Affichages: 69

Discussions similaires