Sub 旧式窗体() '窗体域中循环 Dim youText As FormField For Each youText In ActiveDocument.FormFields If youText.TextInput = True Then youText.Result = "窗体文本框" End If Next End Sub Sub 旧式控件() '控件 ThisDocument.TextBox1.Text = "控件文本框" End Sub '2007新增的两个文本控件 Sub 格式文本() '格式文本可以在这个控件中放很多内容,包括插入图片等 Dim myControl As ContentControl Dim myRange As Range For Each myControl In ActiveDocument.ContentControls If myControl.Type = wdContentControlRichText Then myControl.Range.Text = "2007格式文本控件" myControl.Range.Font.Color = wdColorBlack Set myRange = ActiveDocument.Range(myControl.Range.Start, myControl.Range.Start + 4) myRange.Font.Color = wdColorRed End If Next End Sub Sub 纯文本() '纯文本相当于就是只能按文本,仅字体大小,字号等都是一致的 Dim myControl As ContentControl Dim myRange As Range For Each myControl In ActiveDocument.ContentControls If myControl.Type = wdContentControlText Then myControl.Range.Text = "2007纯文本内容控件" myControl.Range.Font.Color = wdColorBlack Set myRange = ActiveDocument.Range(myControl.Range.Start, myControl.Range.Start + 4) myRange.Font.Color = wdColorBlue End If Next End Sub |