Macro VBA coller une ligne d'une table word avec le format

cs_luyo Messages postés 3 Date d'inscription jeudi 27 novembre 2008 Statut Membre Dernière intervention 1 décembre 2008 - 27 nov. 2008 à 00:20
cs_luyo Messages postés 3 Date d'inscription jeudi 27 novembre 2008 Statut Membre Dernière intervention 1 décembre 2008 - 1 déc. 2008 à 18:44
Je suis en train de creer une macro pour creer un email automatique avec une ligne d'une table de mon document word mais je ne recupere que le texte dans la ligne pas le format.

Sub Tools_and_Process()

Dim updating As Table
Set updating = ActiveDocument.Tables(1)
updating.Select

Dim ligne As Row
Dim Edition As String
Set ligne = updating.Rows.Last
ligne.Select
Selection.Copy

If MsgBox("Do you need to send an email?", vbYesNo + vbQuestion) = vbNo Then
            Else
            Dim P As Outlook.Application
            Dim Mess2 As Outlook.MailItem
            Set P = New Outlook.Application
            Set Mess2 = P.CreateItem(olMailItem)
            Mess2.To = "arnaud.evrard@blabla.com"
            Mess2.Body =  "Hi," & ligne.Range   & "Thanks you," & vbCrLf & vbCrLf & "Tools and Process Team"
            Mess2.Subject = "Update"
            Mess2.Display
 
            Set Mess2 = Nothing
            Set P = Nothing
            End If

End Sub

La fonction  ligne.Range copie le contenu des case l'une apres l'autre dans mon e-mail.
j'ai teste les :
Selection.Paste
select.pasteandformat un peu tout mais je ne trouve pas!
j'ai limpression que le passage word a outlook pose des probleme

mais si une fois le mail ouvert je fais ctrl+v ca copie tout comme il faut!!!

un peu d'aide ?????????

Merci

3 réponses

cs_luyo Messages postés 3 Date d'inscription jeudi 27 novembre 2008 Statut Membre Dernière intervention 1 décembre 2008
27 nov. 2008 à 00:30
Pour un peu plus de clarte:
voila ce que je veux:
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><meta name="ProgId" content="Word.Document" /><meta name="Generator" content="Microsoft Word 11" /><meta name="Originator" content="Microsoft Word 11" /><link rel="File-List" href="file:///C:%5CDOCUME%7E1%5CLC100003%5CLOCALS%7E1%5CTemp%5Cmsohtml1%5C01%5Cclip_filelist.xml" /><!--[if gte mso 9]><xml>
<w:WordDocument>
<w:View>Normal</w:View>
<w:Zoom>0</w:Zoom>
<w:PunctuationKerning/>
<w:ValidateAgainstSchemas/>
<w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid>
<w:IgnoreMixedContent>false</w:IgnoreMixedContent>
<w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText>
<w:Compatibility>
<w:BreakWrappedTables/>
<w:SnapToGridInCell/>
<w:WrapTextWithPunct/>
<w:UseAsianBreakRules/>
<w:DontGrowAutofit/>
</w:Compatibility>
<w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel>
</w:WordDocument>
</xml><![endif]--><!--[if gte mso 9]><xml>
<w:LatentStyles DefLockedState="false" LatentStyleCount="156">
</w:LatentStyles>
</xml><![endif]--><style><!--
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{mso-style-parent:"";
margin:0in;
margin-bottom:.0001pt;
mso-pagination:widow-orphan;
font-size:12.0pt;
font-family:"Times New Roman";
mso-fareast-font-family:"Times New Roman";}
p.Texte, li.Texte, div.Texte
{mso-style-name:Texte;
margin-top:0in;
margin-right:0in;
margin-bottom:6.0pt;
margin-left:34.0pt;
mso-pagination:widow-orphan;
font-size:11.0pt;
mso-bidi-font-size:10.0pt;
font-family:Arial;
mso-fareast-font-family:"Times New Roman";
mso-bidi-font-family:"Times New Roman";
mso-ansi-language:FR;
mso-fareast-language:FR;}
@page Section1
{size:8.5in 11.0in;
margin:1.0in 1.25in 1.0in 1.25in;
mso-header-margin:.5in;
mso-footer-margin:.5in;
mso-paper-source:0;}
div.Section1
{page:Section1;}
--></style><!--[if gte mso 10]>
<style>
/* Style Definitions */
table.MsoNormalTable
{mso-style-name:"Table Normal";
mso-tstyle-rowband-size:0;
mso-tstyle-colband-size:0;
mso-style-noshow:yes;
mso-style-parent:"";
mso-padding-alt:0in 5.4pt 0in 5.4pt;
mso-para-margin:0in;
mso-para-margin-bottom:.0001pt;
mso-pagination:widow-orphan;
font-size:10.0pt;
font-family:"Times New Roman";
mso-ansi-language:#0400;
mso-fareast-language:#0400;
mso-bidi-language:#0400;}
</style>
<![endif]-->4

, August 15 2008

, 22

24

, Renaming

, hhhh

voila ce que j'ai:

4
August 15
2008
22
24
Renaming
hhhh
0
Calade Messages postés 1207 Date d'inscription dimanche 20 avril 2003 Statut Membre Dernière intervention 4 juin 2016 10
27 nov. 2008 à 14:35
Bonjour,

   Je ne suis pas sur à 100% mais il semble que d'après ta copie d'écran ton doc Word contienne un tableau que tu veux lui aussi copier et c'est là où le bât blesse. Je pense qu'il faudrait sélectionner le tableau et le texte qu'il contient en un seul bloc.

   Puisque tu dis qu'un CTRL+V fonctionne, pourquoi n'essaie-tu pas de passer par le presse-papier. Même si ce n'est pas très orthodoxe.

   En espérant t'aider.

Calade
0
cs_luyo Messages postés 3 Date d'inscription jeudi 27 novembre 2008 Statut Membre Dernière intervention 1 décembre 2008
1 déc. 2008 à 18:44
J'ai deja essayer et cela ne fonctionne pas . il refuse ma requete (select.pasteandformat)
meme avec un nouveau document word avec tout mon text que je copie entierement ca ne fonctionne pas!

Tant pis je vais faire avec1!!!

MERCI
0
Rejoignez-nous