{RESOLVED} Checking a checkbox in word from within VB.Net
Hi, I have a word template and I'm able to insert text to it from within a VB app but I have a check box in word I'm trying to check but I dont' know how to go about it. Here's the code I got from vbforums (works with regular texts) but can't figure out how to check boxes.. any help please? thanks
VB Code:
Private Sub GenerateDoc()
Dim app As Word.Application
Dim doc As Word.Document
Dim bookmark As Word.Bookmark
Dim bookmarkValue As Object
Dim outputFileName As String
Dim fileName As String = "C:\Documents and Settings\me\My Documents\temp.doc"
'create the application object
app = CreateObject("Word.Application")
'open the document
app.Documents.Open(fileName)
'copy and save as
doc = app.ActiveDocument
outputFileName = "C:\Documents and Settings\me\My Documents\temm" & Format(Today, "yyyymmdd") & ".doc"
doc.SaveAs(outputFileName)
'iterate through the bookmarks and find the matching field values
For Each bookmark In doc.Bookmarks
'If bookmark.Name = "Check1" Then
' bookmark.Start = 1
'Else
'get the value for the bookmark
bookmarkValue = TextBox2.Text
If IsNothing(bookmarkValue) Then
MsgBox("Couldn't find " & bookmark.Name)
End If
'get the value for the bookmark
bookmark.Range.Text = TextBox2.Text
'End If
Next
doc.Close()
End Sub
Re: Checking a checkbox in word from within VB.Net
A Word Checkbox can be of at least 2 different types, each requiring its own logic in order to access is value. Did you add a ActiveX control checkbox or a Word Formscheckbox?
Re: Checking a checkbox in word from within VB.Net
I added a word formscheckbox from the Forms toolbar in MS word