[英]Visual Basic word table bold / not bold
I'm currently reading CSV files and putting them into a word document. 我目前正在读取CSV文件,并将其放入Word文档中。 Now my question is if its possible to write the text in the cell both bold and the entry from the csv not bold.
现在我的问题是,是否有可能在单元格中将文本写成粗体,而将csv中的条目写成非粗体。 I know the code below puts all the info in the cell on not bold but this may show what I want.
我知道下面的代码将所有信息放在单元格中而不是粗体,但这可能显示我想要的。
oTable.Cell(2, 1).Range.Font.Bold = True
oTable.Cell(2, 1).Range.Text = "Vurnerability description: "
oTable.Cell(2, 1).Range.Font.Bold = False
oTable.Cell(2, 1).Range.Text += openvasCSV(i)(9)
Pretty disgusting, but it works. 真令人作呕,但可以。 I couldn't avoid using Select though, would love to see a solution where it is not needed.
我无法避免使用Select,但愿在不需要的地方看到一个解决方案。
oTable.Cell(2, 1).Select
Selection.Font.Bold = True
Selection.TypeText "üüü"
Selection.TypeParagraph
Selection.Font.Bold = False
Selection.TypeText "öööö"
The key is using .Font
, not .Range
, and setting the Bold
property for the current run only. 关键是使用
.Font
而不是.Range
,并且仅为当前运行设置Bold
属性。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.