As an extension to being able to replace existing text strings with alternate text string and wingdings in a Word document, I want to set:
1. the background cell colour when the existing string is in a table;
2. the background paragraph cell colour when the existing string is not in a table.
I can find out whether or not the existing text string is in a cell using
$selection->Find->ClearFormatting;
$selection->Find->{Text} = $existing_string;
$find_sb_item = $selection->Find->Execute;
$intable_res = 0;
if($find_sb_item == 1) {
$intable_res = $selection->Information(wdWithInTable);
}
with $intable being 1 with the selection point is in the table and 0 when not.
I found in http://www.microsoft.com/technet/scriptcenter/resources/officetips/apr05/tips0407.mspx the following code for VBA
Const wdColorWhite = 16777215
Const wdColorGray10 = 15132390
Const wdColorYellow = 65535
Set objWord = CreateObject("Word.Application")
objWord.Visible = True
Set objDoc = objWord.Documents.Add()
Set objSelection = objWord.Selection
i = 1
objSelection.ParagraphFormat.Shading.BackgroundPatternColor = wdColorG
+ray10
objSelection.TypeText "This is the first paragraph."
objSelection.TypeParagraph()
I always struggle going from VBA to Perl, however, I thought that the following may work.
$wdColorGray10 = 15132390;
$selection->ParagraphFormat->Shading ({BackgroundPatternColor => $wdCo
+lorGray10});
Sadly nothing happened to either the cell or paragraph background colour. Does any Monk know how to do what I want?</code>
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.