2017-02-14 6 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 
関連する問題