如何找到“阴影”在Word文档中使用从WordOpenXML中恢复的颜色编号 [英] How to find "Shading" in Word document using color number reciving from WordOpenXML

查看:87
本文介绍了如何找到“阴影”在Word文档中使用从WordOpenXML中恢复的颜色编号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我必须更改每个着色  BackgroundPatternColor   to  突出显示
按字符改变字符非常非常慢。最快的方法是使用  。查找 方法。



但是在文档中可以有很多不同的着色颜色(24位颜色)。在WordOpenXML中是......像这样:

 

< w:shd w :VAL = QUOT;清零"瓦特:颜色= QUOT;汽车" w:fill =" 8064A2">

< w:shd w:val =" clear"瓦特:颜色= QUOT;汽车"瓦特:填= QUOT; 8064A2" w:themeFill =" accent4" />



From this xml ,我知道"8064A2"在文档中使用着色颜色 - 即"8064A4"。 number是十六进制RRGGBB掩码,它的意思是  RGB(128,
100,162)
  - hex"80" ;是十进制128等。



但是... function  RGB(128,
100,162)
 返回10642560.我正在寻找的阴影返回-687800321

  Debug.print Selection.Range.Shading.BackgroundPatternColor  



所以,我认为  accent4
做点什么,但是什么?



如何从RGB接收-687800321号码(因为  Selection.Find.Shading.BackgroundPatternColor
= -687800321
 效果很好)

解决方案

您可以使用以下内容:

 Sub Test()
MsgBox GetRGB(Selection.Shading.BackgroundPatternColor)
End Sub

功能GetRGB(RGBvalue As Long)As String
Dim StrTmp As String
如果RGBvalue< 0或RGBvalue> 16777215则RGBvalue = 0
StrTmp = StrTmp&" R:"& ; RGBvalue \\ 256 ^ 0mod256
StrTmp = StrTmp&安培; " G:" &安培; RGBvalue \ 256 ^ 1 Mod 256
StrTmp = StrTmp& " B:" &安培; RGBvalue \ 256 ^ 2 Mod 256
GetRGB = StrTmp
结束功能


I have to change every shading BackgroundPatternColor to Highlight. Changing character by character is very, very slow. Fastest way is using .Find method.

But in documents can be a lot of different shading colors (24-bit color). In WordOpenXML is sth. like this:

<w:shd w:val="clear" w:color="auto" w:fill="8064A2">

or

<w:shd w:val="clear" w:color="auto" w:fill="8064A2" w:themeFill="accent4"/>

From this xml, I know that "8064A2" shading color was used in document - that "8064A4" number is hex RRGGBB mask , and its mean RGB(128, 100, 162) - hex "80" is 128 decimal etc.

But... function RGB(128, 100, 162) return 10642560. The shading I'm looking for return -687800321

Debug.print Selection.Range.Shading.BackgroundPatternColor

So, I think that accent4 do something, but what?

How to receive -687800321 number from RGB (because Selection.Find.Shading.BackgroundPatternColor = -687800321 works great)

解决方案

You could use something like:

Sub Test()
MsgBox GetRGB(Selection.Shading.BackgroundPatternColor)
End Sub

Function GetRGB(RGBvalue As Long) As String
Dim StrTmp As String
If RGBvalue < 0 Or RGBvalue > 16777215 Then RGBvalue = 0
StrTmp = StrTmp & " R: " & RGBvalue \ 256 ^ 0 Mod 256
StrTmp = StrTmp & " G: " & RGBvalue \ 256 ^ 1 Mod 256
StrTmp = StrTmp & " B: " & RGBvalue \ 256 ^ 2 Mod 256
GetRGB = StrTmp
End Function


这篇关于如何找到“阴影”在Word文档中使用从WordOpenXML中恢复的颜色编号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆