Solved

Inputting a Check Box object from a visual basic coding

Posted on 2012-03-16
8
221 Views
Last Modified: 2012-03-28
I am working on a word 2003 file that has visual basic coding in it.  I already have coding that asks the user questions and puts the data throughout the document.  The client has asked if a check box can be inserted into the word document from the visual basic code.  Is this possible and if it is, can i have an example of the code?
0
Comment
Question by:KineticNetworking
8 Comments
 
LVL 25

Expert Comment

by:SStory
Comment Utility
0
 
LVL 10

Expert Comment

by:SANTABABY
Comment Utility
With your cursor at the desired position:

    Selection.Range.ContentControls.Add (wdContentControlCheckBox)
0
 
LVL 76

Expert Comment

by:GrahamSkan
Comment Utility
It depends on what type of checkbox.

This will add an ActiveX checkbox at the start of the active document
Sub InsActiveXCheckBox()
Dim ilsh As InlineShape
Dim rng As Range

Set rng = ActiveDocument.Range(0, 0)
Set ilsh = ActiveDocument.InlineShapes.AddOLEControl("Forms.Checkbox.1", rng)
End Sub

Open in new window

and this will add a Forms checkbox
Sub InsFormsCheckBox()
Dim ffld As FormField
Dim rng As Range

Set rng = ActiveDocument.Range(0, 0)
Set ffld = ActiveDocument.FormFields.Add(rng, wdFieldFormCheckBox)
End Sub

Open in new window

0
 

Author Comment

by:KineticNetworking
Comment Utility
I just need to be able to put a plain square in a specific position in the document so after they print it out they can write a check in the box on the paper themselves.  It doesn't need to be interactive in word.  Sorry for the confusion.
0
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 
LVL 76

Accepted Solution

by:
GrahamSkan earned 500 total points
Comment Utility
It isn't clear how you want to define the specific position. This will add a square, anchored at the start of the document, 50 points from the left of the page, and 100 from the top.

    With ActiveDocument
        .Shapes.AddShape msoShapeRectangle, 50, 100, 15, 15, .Range(0, 0)
    End With

Open in new window

0
 

Author Comment

by:KineticNetworking
Comment Utility
The position will be the same place every time if they hit yes to a question.  Most likely on page two of three of the document.
0
 
LVL 76

Expert Comment

by:GrahamSkan
Comment Utility
I don't know how to code for that. If you specify the position, then the code can be written to conform to that. If not, it will be somewhat random, or at least unlikely to  match the requirements.
0
 

Author Comment

by:KineticNetworking
Comment Utility
GrahamSkan,
   Can this

    With ActiveDocument
        .Shapes.AddShape msoShapeRectangle, 50, 100, 15, 15, .Range(0, 0)
    End With

be coded to be place of page 3.  I tested this and after 700 points down it goes off the pages, or it seems like it.
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

There is a feature provided by MS Word that lets you create an Table of Contents for your Word document automatically. To use this feature for other documents there are two steps involved,   1.  Prepare your document for a table of contents (he…
Introduction This tutorial provides instructions on how to properly format your Word document using the inbuilt tools provided. The benefits of using these tools means your documents are more accessible and easily portable to other applications an…
This Micro Tutorial well show you how to find and replace special characters in Microsoft Word. This is similar to carriage returns to convert columns of values from Microsoft Excel into comma separated lists.
This Experts Exchange video Micro Tutorial shows how to tell Microsoft Office that a word is NOT spelled correctly. Microsoft Office has a built-in, main dictionary that is shared by Office apps, including Excel, Outlook, PowerPoint, and Word. When …

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now