Consulting

Results 1 to 2 of 2

Thread: Can I use Excel VBA with data, to create a WinWord form (Consists to control Checkbox

  1. #1
    VBAX Regular
    Joined
    Feb 2017
    Location
    Hong Kong
    Posts
    31
    Location

    Can I use Excel VBA with data, to create a WinWord form (Consists to control Checkbox

    Form to Form.jpg
    Can I use Excel VBA with data, to create a Winword form(Consists to control Checkbox)

    How to use Excel VBA code to control Checkbox ( True / False ) in Winword ?

  2. #2
    The following should get you started

    Sub WriteToWord()
    Dim wdApp As Object
    Dim wdDoc As Object
    Dim bCheck As Boolean
        On Error Resume Next
        Set wdApp = GetObject(, "Word.Application")
        If Err Then
            Set wdApp = CreateObject("Word.Application")
        End If
        Set wdDoc = wdApp.Documents.Add(Template:="C:\Path\DocName.docx")
        If Range("B2") = "Test" Then
            bCheck = True
        Else
            bCheck = False
        End If
        wdDoc.SelectContentControlsByTitle("Title of Checkbox").Item(1).Checked = bCheck
    End Sub
    Graham Mayor - MS MVP (Word) 2002-2019
    Visit my web site for more programming tips and ready made processes
    http://www.gmayor.com

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •