Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/excel/26.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Excel VBA:将特定文本设置为粗体或斜体_Excel_Vba - Fatal编程技术网

Excel VBA:将特定文本设置为粗体或斜体

Excel VBA:将特定文本设置为粗体或斜体,excel,vba,Excel,Vba,我对宏非常陌生。我期待着为打印斜体和粗体字符串其余部分的代码 e、 g 大家好,祝贺新的作业 我能够以粗体或斜体打印整个字符串,但无法找到满足我要求的代码 另外,将文本拆分到伪变量中并加入那些应用格式的帖子似乎是一个冗长的选项。处理一下这个问题,它将完成您在示例中使用的操作 Sub SetBoldAndItalicInCell() ActiveCell.FormulaR1C1 = "Hi There, congratulation for new assignment." Wit

我对宏非常陌生。我期待着为打印斜体和粗体字符串其余部分的代码

e、 g

大家好,祝贺新的作业

我能够以粗体或斜体打印整个字符串,但无法找到满足我要求的代码


另外,将文本拆分到伪变量中并加入那些应用格式的帖子似乎是一个冗长的选项。

处理一下这个问题,它将完成您在示例中使用的操作

Sub SetBoldAndItalicInCell()
    ActiveCell.FormulaR1C1 = "Hi There, congratulation for new assignment."
    With ActiveCell.Characters(Start:=1, Length:=3).Font.FontStyle = "Regular"
    ActiveCell.Characters(Start:=4, Length:=5).Font.FontStyle = "Bold Italic"
    ActiveCell.Characters(Start:=9, Length:=24).Font.FontStyle = "Regular"
    ActiveCell.Characters(Start:=33, Length:=11).Font.FontStyle = "Bold"
    ActiveCell.Characters(Start:=44, Length:=1).Font.FontStyle = "Regular"
End Sub
查看Range.Character()函数。可能与