Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Change MSword table cell background programatically
Message
De
07/07/2009 17:18:38
 
Information générale
Forum:
Visual FoxPro
Catégorie:
COM/DCOM et OLE Automation
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows XP SP2
Divers
Thread ID:
01410445
Message ID:
01410746
Vues:
33
Thanks Borislav

I only had a small issue with the following line
oWord.Selection.Shading.BackgroundPatternColor = -553582746
I fixed by finding the right number

Thanks again

>>Can I change the background of a table's cell background programmatically in MS Word document.
>>
>>I am building a matrix that need to have different color based on query result.
>>
>>Thanks
>
>Sure, try this:
>
>
>#define wdTextureNone    0
>#define wdColorAutomatic -16777216
>
>LOCAL oWord AS Word.Application
>oWord = CREATEOBJECT("Word.Application")
>oWord.Documents.Add()
>oWord.Visible = .t.
>oWord.ActiveDocument.Tables.Add(oWord.Selection.Range,3,3) && Add 3x3 grid 
>WITH oWord.ActiveDocument.Tables(1)
>     .Style = "Table Grid"
>     .ApplyStyleHeadingRows = .t.
>     .ApplyStyleLastRow     = .f.
>     .ApplyStyleFirstColumn = .t.
>     .ApplyStyleLastColumn  = .f.
>     .ApplyStyleRowBands    = .t.
>     .ApplyStyleColumnBands = .f.
>ENDWITH
>
>
>oWord.ActiveDocument.Tables(1).Cell(1,2).Select()  && Select cell we want to change
>oWord.Selection.Shading.Texture                = wdTextureNone
>oWord.Selection.Shading.ForegroundPatternColor = wdColorAutomatic
>oWord.Selection.Shading.BackgroundPatternColor = -553582746
>
>oWord.ActiveDocument.Tables(1).Cell(2,1).Select()
>oWord.Selection.Shading.Texture                = wdTextureNone
>oWord.Selection.Shading.ForegroundPatternColor = wdColorAutomatic
>oWord.Selection.Shading.BackgroundPatternColor = -553582746
>
>oWord.ActiveDocument.Tables(1).Cell(2,3).Select()
>oWord.Selection.Shading.Texture                = wdTextureNone
>oWord.Selection.Shading.ForegroundPatternColor = wdColorAutomatic
>oWord.Selection.Shading.BackgroundPatternColor = -553582746
>
>oWord.ActiveDocument.Tables(1).Cell(3,2).Select()
>oWord.Selection.Shading.Texture                = wdTextureNone
>oWord.Selection.Shading.ForegroundPatternColor = wdColorAutomatic
>oWord.Selection.Shading.BackgroundPatternColor = -553582746
>
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform