Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Word automation how to BOLD
Message
De
15/01/2015 15:49:20
 
 
À
15/01/2015 08:33:48
Information générale
Forum:
Visual FoxPro
Catégorie:
COM/DCOM et OLE Automation
Versions des environnements
Visual FoxPro:
VFP 9
OS:
Windows Server 2012
Network:
Windows 2008 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01613678
Message ID:
01613701
Vues:
43
>I am using wordautomation
>I own Tamars book
>
>i need to write into a table cell
>
>1st line
> font.size=10
> font.bold=.t.
>
>2nd line in same cell
> font.size=8
> font.bold=.f.
>
>how can this be done
>
>this does not work
>
>loTable.Cell[liRowNo, 1].RANGE.InsertAfter(ALLTRIM(lcname))
>loTable.Cell[liRowNo, 1].RANGE.Shading.Texture = 50
>
>loTable.Cell[liRowNo, 2].RANGE.InsertAfter(thisform.lcCurrentYear+[:  ]+ALLTRIM(lcVotes) )
>x1=loTable.Cell[liRowNo, 2].RANGE.Font.Size
>
>loTable.Cell[liRowNo, 2].RANGE.Font.Bold = .t.
>loTable.Cell[liRowNo, 2].RANGE.InsertAfter( CHR(13) )
>loTable.Cell[liRowNo, 2].RANGE.Font.Size=8
>loTable.Cell[liRowNo, 2].RANGE.InsertAfter(lcPrevYear+[: (]+lcVotesP +[)])
>loTable.Cell[liRowNo, 2].RANGE.Font.Size=x1
>loTable.Cell[liRowNo, 2].RANGE.Font.Bold =.f.
>
>
>loTable.Cell[liRowNo, 2].RANGE.ParagraphFormat.ALIGNMENT = wdAlignParagraphRight
>IF NOT EMPTY(lcPerc)
>loTable.Cell[liRowNo, 3].RANGE.InsertAfter(ALLTRIM(lcPerc) +[%] + CHR(13) +lcprevyear+[(]+ALLTRIM(lcPercP) +[%)])
>loTable.Cell[liRowNo, 3].RANGE.ParagraphFormat.ALIGNMENT = wdAlignParagraphRight
>ENDIF 
>loTable.Cell[liRowNo, 4].RANGE.InsertAfter(lcPlural + CHR(13) +thisform.lcprevyear+[(]+lcPluralP +[)])
>loTable.Cell[7, 4].RANGE.ParagraphFormat.ALIGNMENT = wdAlignParagraphRight
>
>
>what am I doing wrong

You're addressing the whole cell each time, not just the part of it you're interested in. Use a range variable and have that contain only the content you want the formatting to affect, something like:
loRange = loTable.Cell[liRowNo, 2].RANGE()
loRange.Font.Bold = .t.
loRANGE.InsertAfter( CHR(13) )
loRange.Collapse(1) && I think 1 is the value to collapse to the end
loRANGE.Font.Size=8
loRANGE.InsertAfter(lcPrevYear+[: (]+lcVotesP +[)])
loRANGE.Font.Bold =.f.
loRange.Collapse(1)
loRANGE.Font.Size=x1
This may not be exactly right, but try variations until it works.

Tamar
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform