[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Inputting a Check Box object from a visual basic coding

Posted on 2012-03-16
8
Medium Priority
?
230 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 10

Expert Comment

by:SANTABABY
ID: 37730498
With your cursor at the desired position:

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

Expert Comment

by:GrahamSkan
ID: 37730532
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
Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

 

Author Comment

by:KineticNetworking
ID: 37739701
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
 
LVL 76

Accepted Solution

by:
GrahamSkan earned 1500 total points
ID: 37740252
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
ID: 37744527
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
ID: 37744726
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
ID: 37759242
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

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The Selection object is designed for user interaction. It has a Range property, so it can be used in most places that a Range object can. Recorded macros must use the Selection because they are simply copying what the user is doing. A Range prope…
Shortcuts in Word Just the other day I had a training for Microsoft and they wanted me to show how well the new Windows and Office behaved on a touch device, which by the way is great, but it was only then that I realized that using keyboard shortc…
This video shows where to find templates, what they are used for, and how to create and save a custom template using Microsoft Word.
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.

650 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