2017-02-14 11 views
-1

명확히하기 위해 회사는 Microsoft Word 2016 응용 프로그램 (확인란 외에 채우기 양식 필드 포함)과 함께 작동합니다.모든 필인 양식 필드를 순환하고, 체크 박스를 건너 뛰고, 모두를 일반 텍스트로 변경하려면 어떻게해야합니까?

Test Form Field Options

우리는 이미 각 양식 필드의 도움말 텍스트를 제거하기 위해 매크로를 만든 활성 문서 전반에 걸쳐 인해 새로운 SOP에 : 아래 그림과 같이 양식 필드는 숫자, 날짜 그냥 일반 텍스트를 가질 수 있습니다

Sub FillInHelpRemoval() 
Dim fld As FormField 
    For Each fld In ActiveDocument.FormFields 
      fld.StatusText = "" 
    Next 
End Sub 

난을 가지고 그들의 각 하나를 변경 확인란을 건너 뛰는, 각 양식 필드를 순환 할 수있는 방법 위의 매크로에 추가하는 방법을 알아 내기 위해 노력하고있다 보내고있어 문제 : 아래 그림과 같이 아래의 속성 ...

TextInput.EditType Type:=wdRegularText, Default:="", Format:="" 

... TextInput.EditType 유형wdNumberText 또는 wdDateText 경우에 상관없이.

이렇게하면 작업을 처리하는 데 필요한 많은 클릭과 단계가 생략됩니다.

답변

0

내 감독자가 필요로하는 코드를 생각해 냈지만 포함 된 모든 코드는 매크로 실행에 필요하지 않을 수도 있지만 아무 것도 제거하는 것이 두려워요. 웃음!

하지만 향후에 유사한 VBA 해상도를 찾고있는 사용자 또는이를 명확히하고 코딩 혼란을 줄이는 사람들을 위해 여기에 포함 할 것입니다.

Sub FillInHelpRemoval() 

Dim objFld As FormField 
Dim intCount, intLoop As Integer 
Dim intNum, intText, intDate, intCheck As Integer 
Dim intLen As Integer 
Dim intLoop2 As Integer 
Dim lngStr As Long 


For Each objFld In ActiveDocument.FormFields 
    intCount = intCount + 1 
Next 

If ActiveDocument.ProtectionType <> wdNoProtection Then ActiveDocument.Unprotect 

On Error Resume Next 
For intLoop = 1 To intCount 
    Select Case True 
    Case ActiveDocument.FormFields(intLoop).Type = 70 'text 
     ActiveDocument.FormFields(intLoop).Select 

     If ActiveDocument.FormFields(intLoop).TextInput.Type = wdDateText Then 
      ActiveDocument.FormFields(intLoop).Select 
      With Selection.FormFields(1) 

       With .TextInput 
        .EditType Type:=wdRegularText, Default:="", Format:="" 
       End With 

      End With 

      intDate = intDate + 1 
     Else 
      If ActiveDocument.FormFields(intLoop).TextInput.Type = wdNumberText Then 
       ActiveDocument.FormFields(intLoop).Select 
       With Selection.FormFields(1) 

        With .TextInput 
         .EditType Type:=wdRegularText, Default:="", Format:="" 
        End With 
                                                              End With 
       intNum = intNum + 1 

      End If 
     End If 

    Case Else 
     Debug.Print ActiveDocument.FormFields(intLoop).Type 
    End Select 
Next intLoop 

'Call FillInHelpRemoval 

For Each objFld In ActiveDocument.FormFields 
    objFld.Select 
    With Selection.FormFields(1) 
     .StatusText = "" 
    End With 

    Next 
End Sub