|
-
Aug 2nd, 2005, 11:00 PM
#1
Thread Starter
Junior Member
{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
Last edited by Makavelli; Aug 5th, 2005 at 12:33 PM.
Reason: Resolved
-
Aug 2nd, 2005, 11:33 PM
#2
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?
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Aug 3rd, 2005, 09:17 AM
#3
Thread Starter
Junior Member
Re: Checking a checkbox in word from within VB.Net
I added a word formscheckbox from the Forms toolbar in MS word
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|