Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Change MSword table cell background programatically
Message
 
À
06/07/2009 22:28:00
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:
01410478
Vues:
48
This message has been marked as the solution to the initial question of the thread.
>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
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform