2016-03-24 51 views

回答

2

可以使用下面的示例VBA代码段(字体在斜体)实现它:

Worksheets("Sheet1").Range("A1").Font.Italic = True 

或设置斜体/粗体类似如下:

Worksheets("Sheet1").Range("A1").Font.FontStyle = "Bold Italic" 

(re:https://msdn.microsoft.com/en-us/library/office/ff194438.aspx

在更普遍的情况下,您可以在Excel Cell或应用该技术整个文本只是它的一部分,如下图所示:

'demonstrate font Italic/Bold applied to part of Excel cell 
Sub DemoFontItalicBold() 
    Range("A1").Value = "This is Just a Sample Text" 

    'display "A1" 4 initial chars in bold/italic typeface 
    Range("A1").Characters(1, 4).Font.FontStyle = "Bold Italic" 

    'set the word "Sample" in Italic typeface 
    Range("A1").Characters(WorksheetFunction.Find("Sample", Range("A1").Value, 1), Len("Sample")).Font.Italic = True 

    'set the word "Text" in bold typeface 
    Range("A1").Characters(WorksheetFunction.Find("Text", Range("A1").Value, 1), Len("Text")).Font.Bold = True 
End Sub 
相关问题