다음 코드는 런타임 오류 451 "속성 Let 프로 시저가 정의되지 않았고 속성 가져 오기 프로 시저가 개체를 반환하지 않았습니다"라는 메시지를 표시하더라도 성공적으로 작동합니다.
디버거 With oCC.Range.Style("Placeholder Text").Font
가 범인으로 플래그 를 지정합니다.
값을 입력하거나 삭제할 때 재설정되지 않도록 자리 표시 자 텍스트에 스타일을 적용해야합니다.
없어진 물건 있어요?
Dim oTable As Table
Dim ocell As Cell
Dim oCC As ContentControl
Dim oNewRow As Row
Set oTable = ActiveDocument.Tables(1)
Set oNewRow = oTable.Rows.Add
Set ocell = oNewRow.Cells(1)
Set oCC = ActiveDocument.ContentControls.Add(wdContentControlRichText, ocell.Range)
With oCC
.DefaultTextStyle = "Style1"
.Tag = "Test1"
.Setplaceholdertext , , "test1"
If oCC.ShowingPlaceholderText Then
With oCC.Range.Style("Placeholder Text").Font
.Name = "Arial"
.Size = 8
.ColorIndex = wdRed
.Italic = True
End With
End If
End With
그래서 나는 그것을 어떻게 든 알아 냈다.
With ActiveDocument.Styles("Placeholder Text").Font
아래를 사용 하면 전체 문서에 대한 자리 표시 자 텍스트 프레임 워크가 설정되고 재설정되지 않습니다.
Dim oTable As Table
Dim ocell As Cell
Dim oCC As ContentControl
Dim oNewRow As Row
Set oTable = ActiveDocument.Tables(1)
Set oNewRow = oTable.Rows.Add
Set ocell = oNewRow.Cells(1)
Set oCC = ActiveDocument.ContentControls.Add(wdContentControlRichText, ocell.Range)
With oCC
.DefaultTextStyle = "Style1"
.Tag = "Test1"
.Setplaceholdertext , , "test1"
If oCC.ShowingPlaceholderText Then
**With ActiveDocument.Styles("Placeholder Text").Font**
.Name = "Arial"
.Size = 8
.ColorIndex = wdRed
.Italic = True
End With
End If
End With
그런 다음 제 경우에는 문서 내의 각 후속 자리 표시 자 텍스트에 대해 With oCC.Range.Font
아래와 같이 각각 서식을 수정할 수 있습니다.
Set ocell = oNewRow.Cells(2)
Set oCC = ActiveDocument.ContentControls.Add(wdContentControlRichText, ocell.Range)
With oCC
.DefaultTextStyle = "Style2"
.Tag = "test2"
.SetPlaceholderText , , "test2"
If oCC.ShowingPlaceholderText Then
**With oCC.Range.Font**
.Name = "Arial"
.Size = 12
.ColorIndex = wdBlack
.Italic = True
End With
End If
End With
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다