web-development-kb-ko.site

Word 2007의 모든 상호 참조에 특정 스타일을 할당 할 수 있습니까?

더 이상 추가 할 것은 없지만 Word 2007 문서에있는 모든 교차 참조 스타일을 한 번에 변경하고 싶습니다. 그러나 나는 그것을하는 방법을 모른다. 어떻게 할 수 있습니까?

35
Drake

일부 상호 참조 유형은 "강렬한 참조"스타일로 자동 서식이 지정되지만 대부분은 "일반"텍스트로 서식이 지정됩니다.

상호 참조 텍스트에 "강렬한 참조"스타일을 적용하려면

  • 텍스트를 선택하십시오
  • 리본에서 "홈"탭을 선택하십시오.
  • 리본 메뉴의 "스타일"그룹에있는 드롭 다운 버튼 또는 드롭 다운 버튼을 사용하여 "강렬한 참조"스타일 (또는 원하는 경우 다른 스타일)을 선택하십시오.

주어진 스타일의 모든 텍스트 모양을 변경하려면

  • 리본에서 "홈"탭을 선택하십시오.
  • 리본 메뉴의 "스타일"그룹에있는 드롭 다운 버튼을 사용하여 "스타일 적용 ..."을 선택하십시오.
  • "스타일 적용"대화 상자의 "스타일 이름"에서 변경할 스타일의 이름을 선택하십시오 (예 : "강렬한 참조")
  • "수정 ..."버튼을 클릭하십시오
  • 자신에게 맞게 형식을 변경하고 "확인"을 클릭하십시오

한 번에 모든 상호 참조에 스타일을 적용하려면

  • 프레스 Alt+F9 필드 코드를 보여주기 위해
  • 리본에서 "홈"탭을 선택하십시오.
  • "편집"그룹에서 "바꾸기"를 클릭하십시오
  • "찾을 내용"필드에 ^19 REF
    • (이것은 캐럿 1-9 공간 R-E-F입니다)
  • "바꾸기"필드를 클릭하고 아무 것도 입력하지 마십시오
  • "추가"버튼을 클릭하십시오
  • 대화 상자의 맨 아래 섹션에는 "바꾸기"라는 제목이 있어야합니다 (그 뒤에 가로 규칙이 있음).
  • "포맷"버튼을 클릭하고 "스타일 ..."을 선택하십시오.
  • 스타일을 선택하고 (예 : "강렬한 참조") 확인을 클릭하십시오.
  • "바꾸기"필드에서 선택한 스타일이 표시됩니다.
  • 용감하다고 생각되면 "모두 바꾸기"를 클릭하거나 "다음 찾기"및 "바꾸기"를 사용하여 각 참조 필드 코드 스타일을 개별적으로 단계별로 바꾸거나 건너 뛰십시오.
  • 프레스 Alt+F9 필드 코드를 숨기려면

찾기 및 바꾸기의 특수 코드에 대한 자세한 내용은 이 페이지 를 참조하십시오.

다음은 스위치를 추가 할 매크로입니다. \* mergeformat 각 필드에. 이 스위치는 필드 업데이트를 수행 할 때 서식이 손실되지 않도록하는 데 필요합니다. 매크로를 키 스트로크에 할당 할 수 있으며 키 스트로크를 누를 때마다 한 번에 하나씩 필드를 단계별로 실행합니다. 매크로를 편집하여 전체 문서를 반복하여 프로세스를 자동화 할 수도 있습니다.

Sub mf()
'
' mf Macro
' Find cross references and add \* mergeformat
'
    Selection.Find.ClearFormatting
    With Selection.Find
        .Text = "^19 REF"
        .Forward = True
        .Wrap = wdFindContinue
        .Format = True
        .MatchCase = False
        .MatchWholeWord = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Selection.Find.Execute
    Selection.MoveRight Unit:=wdCharacter, Count:=1
    Selection.MoveLeft Unit:=wdCharacter, Count:=1
    Selection.TypeText Text:="\* mergeformat "
    Selection.Find.Execute
End Sub
  • 프레스 Alt+F9 필드 코드를 보여주기 위해
  • 다음 매크로를 사용하여 CHARFORMAT을 모든 상호 참조에 추가하십시오. 이 매크로는 문자열이 아직없는 경우에만 필드에 문자열을 추가합니다.

    Sub SetCHARFORMAT()
    '
    ' Set CHARFORMAT switch to all {REF} fields. Replace MERGEFORMAT.
    '
    '
        Dim oField As Field
        Dim oRng As Range
        For Each oField In ActiveDocument.Fields
        'For Each oField In Selection.Fields
            If InStr(1, oField.Code, "REF ") = 2 Then
                If InStr(1, oField.Code, "MERGEFORMAT") <> 0 Then
                    oField.Code.Text = Replace(oField.Code.Text, "MERGEFORMAT", "CHARFORMAT")
                End If
                If InStr(1, oField.Code, "CHARFORMAT") = 0 Then
                    oField.Code.Text = oField.Code.Text + "\* CHARFORMAT "
                End If
            End If
        Next oField
    
    
    End Sub
    
  • 이 매크로를 사용하여 "미묘한 참조"스타일로 모든 상호 참조의 형식을 지정하십시오 (해당 스타일이 있고 필드 코드가 표시되는지 확인하십시오).

    Sub SetCrossRefStyle()
    '
    ' Macro to set styole of all cross references to "Subtle Reference"
    '
    '
        Selection.Find.ClearFormatting
        Selection.Find.Replacement.ClearFormatting
        Selection.Find.Replacement.Style = ActiveDocument.Styles( _
            "Subtle Reference")
        With Selection.Find
            .Text = "^19 REF"
            .Replacement.Text = ""
            .Forward = True
            .Wrap = wdFindContinue
            .Format = True
            .MatchCase = False
            .MatchWholeWord = False
            .MatchKashida = False
            .MatchDiacritics = False
            .MatchAlefHamza = False
            .MatchControl = False
            .MatchWildcards = False
            .MatchSoundsLike = False
            .MatchAllWordForms = False
        End With
        Selection.Find.Execute Replace:=wdReplaceAll
    End Sub
    
  • 프레스 Alt+F9 필드 코드를 숨기려면

5
cyborg

사이보그가 업로드 한 매크로를 편집하면 필드 코드 표시 및 숨기기를 쉽게 자동화 할 수 있습니다. 업데이트 할 때마다 토글 필드 코드를 사용할 필요가 없습니다. 필드 코드 토글을 추가하기 위해 다음 코드를 사용했습니다.

ActiveDocument.ActiveWindow.View.ShowFieldCodes = False

완전한 매크로는 다음과 같습니다.

Sub SetCrossRefStyle()
'
' Macro to set styole of all cross references to "Subtle Reference"
'
'
ActiveDocument.ActiveWindow.View.ShowFieldCodes = True
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
Selection.Find.Replacement.Style = ActiveDocument.Styles( _
    "Subtle Reference")
With Selection.Find
    .Text = "^19 REF"
    .Replacement.Text = ""
    .Forward = True
    .Wrap = wdFindContinue
    .Format = True
    .MatchCase = False
    .MatchWholeWord = False
    .MatchKashida = False
    .MatchDiacritics = False
    .MatchAlefHamza = False
    .MatchControl = False
    .MatchWildcards = False
    .MatchSoundsLike = False
    .MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
ActiveDocument.ActiveWindow.View.ShowFieldCodes = False
End Sub

Word에서 작업 속도를 높이기 위해 매크로를 사용하는 것은 이번이 처음입니다. 유용한 매크로에 감사합니다.

3
Jaykrushna patel

위의 답변을 다른 함수와 결합하여 문서 '스토리'를 반복하여 문서 본문, 머리글, 바닥 글 및 도형의 텍스트에 스타일을 적용합니다.

아래의 SetCrossRefStyle () 매크로를 호출하여 모든 상호 참조에 "강렬한 참조"스타일을 적용하십시오.

Sub m_SetCHARFORMAT(textRanges As Collection)
' https://superuser.com/questions/13531/is-it-possible-to-assign-a-specific-style-to-all-cross-references-in-Word-2007
'
' Set CHARFORMAT switch to all {REF} fields. Replace MERGEFORMAT.
' Requires ActiveDocument.ActiveWindow.View.ShowFieldCodes = True
'
    Dim oField As Field
    Dim oRng As Range
    For Each oRng In textRanges
        For Each oField In oRng.Fields
            If InStr(1, oField.Code, "REF ") = 2 Then
                If InStr(1, oField.Code, "MERGEFORMAT") <> 0 Then
                    oField.Code.Text = Replace(oField.Code.Text, "MERGEFORMAT", "CHARFORMAT")
                End If
                If InStr(1, oField.Code, "CHARFORMAT") = 0 Then
                    oField.Code.Text = oField.Code.Text + "\* CHARFORMAT "
                End If
            End If
        Next oField
    Next oRng
End Sub


Sub m_AddCrossRefStyle(textRanges As Collection)
' https://superuser.com/questions/13531/is-it-possible-to-assign-a-specific-style-to-all-cross-references-in-Word-2007
'
' Macro to set style of all cross references to "Intense Reference"
' Requires ActiveDocument.ActiveWindow.View.ShowFieldCodes = True
'
    For Each oRng In textRanges
        oRng.Find.ClearFormatting
        oRng.Find.Replacement.ClearFormatting
        oRng.Find.Replacement.Style = ActiveDocument.Styles("Intense Reference")
        With oRng.Find
            .Text = "^19 REF"
            .Replacement.Text = ""
            .Forward = True
            .Wrap = wdFindContinue
            .Format = True
            .MatchCase = False
            .MatchWholeWord = False
            .MatchKashida = False
            .MatchDiacritics = False
            .MatchAlefHamza = False
            .MatchControl = False
            .MatchWildcards = False
            .MatchSoundsLike = False
            .MatchAllWordForms = False
        End With
        oRng.Find.Execute Replace:=wdReplaceAll
    Next oRng
End Sub


Function m_GetAllTextRanges() As Collection
' https://wordmvp.com/FAQs/Customization/ReplaceAnywhere.htm
' https://www.mrexcel.com/forum/Excel-questions/443052-returning-collection-function.html
'
' Get text ranges in all document parts.
'
    Set m_GetAllTextRanges = New Collection
    For Each rngStory In ActiveDocument.StoryRanges
        'Iterate through all linked stories
        Do
            m_GetAllTextRanges.Add rngStory
            On Error Resume Next
            Select Case rngStory.StoryType
                Case 6, 7, 8, 9, 10, 11
                If rngStory.ShapeRange.Count > 0 Then
                    For Each oShp In rngStory.ShapeRange
                        If oShp.TextFrame.HasText Then
                            m_GetAllTextRanges.Add oShp.TextFrame.TextRange
                        End If
                    Next
                End If
                Case Else
                    'Do Nothing
            End Select
            On Error GoTo 0
            'Get next linked story (if any)
            Set rngStory = rngStory.NextStoryRange
        Loop Until rngStory Is Nothing
    Next
End Function

Sub SetCrossRefStyle()
'
' 1. Get all text ranges since Selection.Find only works on document body, but not on headers/footers
' 2. Add CHARFORMAT to make styling persistent
' 3. Add styling to all references
'
    Dim textRanges As Collection
    Set textRanges = m_GetAllTextRanges
    ActiveDocument.ActiveWindow.View.ShowFieldCodes = True
    m_SetCHARFORMAT textRanges
    m_AddCrossRefStyle textRanges
    ActiveDocument.ActiveWindow.View.ShowFieldCodes = False
End Sub
0
eymre

빠르고 효과적인 방법 :

  1. 참조에 사용할 형식이있는 텍스트를 선택하십시오.
  2. 리본에서 Home 탭을 선택하십시오.
  3. Normal 스타일을 마우스 오른쪽 버튼으로 클릭하고 선택 항목과 일치하도록 표준 업데이트를 선택하십시오.
  4. 로 참조 업데이트 CtrlAF9.
0
Evgeny

이 매크로는 현재 커서 위치에 상호 참조를 삽입하기 위해 상호 참조 대화 상자를 엽니 다.

참조를 삽입 한 후 외부 참조 대화 상자를 닫으면 삽입 된 상호 참조를 위첨자로 서식 지정하기 위해 매크로가 다시 시작됩니다.

Sub XrefSuper()
'
' This opens the Cross Reference dialogue box to insert a cross reference at the current cursor position.
'   When the dialogue box is closed after inserting the reference the macro resumes to format the inserted cross reference to superscript.
'
'
Dim wc As Integer
    wc = ActiveDocument.Characters.Count

Dim dlg As Dialog
    Set dlg = Dialogs(wdDialogInsertCrossReference)
        dlg.Show 'Open dialogue and perform the insertion from the dialog box) 
                 'Macro continues after closing CrossRef dialogue box

    If wc = ActiveDocument.Characters.Count Then Exit Sub   'If we failed to insert something then exit

    Selection.MoveLeft Unit:=wdCharacter, Count:=1, Extend:=wdExtend
    Selection.Font.Superscript = wdToggle
    Selection.MoveRight Unit:=wdCharacter, Count:=1
    Selection.Font.Superscript = wdToggle
End Sub

외부 참조 대화 상자를 여는 방법에 대해 Graham Skan at ExpertsExchange 에게 감사합니다.

0
TJH