Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / March 2007

Tip: Looking for answers? Try searching our database.

Template Form fill using check boxes in word

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
CS Hayes - 07 Mar 2007 14:58 GMT
I used a piece of code for automaticly filling in a document through a user
form.  I now need the code to fill in form check boxes on my document.  Can I
access these through code?  If so, how?

sample code:
With ActiveDocument
   .Bookmarks("customer").Range.InsertBefore customer
End with
   If enclosingx = yes Then
   ActiveDocument.Bookmarks("enclosingx") = yes
   End If

The "with" statement works fine.

"Enclosingx" is a checkbox on the document, this piece of code does not work.
Signature

Chris Hayes
Still a beginner

Greg Maxey - 07 Mar 2007 17:31 GMT
Chris,

I am not clear on what it is that you are trying to do, but you
mention UserForms and document checkboxes.  This might help:

http://gregmaxey.mvps.org/Interactive_UserForm_Checkboxes.htm

> I used a piece of code for automaticly filling in a document through a user
> form.  I now need the code to fill in form check boxes on my document.  Can I
[quoted text clipped - 14 lines]
> Chris Hayes
> Still a beginner
CS Hayes - 07 Mar 2007 18:33 GMT
yes, this is the answer I needed (and more!) thanks!
Signature

Chris Hayes
Still a beginner

> Chris,
>
[quoted text clipped - 21 lines]
> > Chris Hayes
> > Still a beginner
CS Hayes - 07 Mar 2007 19:52 GMT
I have a catch:

Sub UncheckIt()
****   oAutoTextUnchkBox.Insert Where:=Selection.Range****
End Sub

and:

Sub CheckIt()
Dim oBMs As Bookmarks
Dim oStr As String
Dim oRng As Word.Range
'ActiveDocument.Unprotect 'Activate this line if using a protected Word form
Set oBMs = ActiveDocument.Bookmarks
oStr = Selection.Bookmarks(1).Name
Set oRng = oBMs(oStr).Range
****ActiveDocument.AttachedTemplate.AutoTextEntries("CB").Insert
Where:=oRng****
oBMs.Add oStr, oRng
oRng.Font.Color = wdColorBlack
'ActiveDocument.Protect wdAllowOnlyFormFields, NoReset:=True 'Activate this
line as required.
End Sub

it freezes at the astericked line
Signature

Chris Hayes
Still a beginner

> yes, this is the answer I needed (and more!) thanks!
>
[quoted text clipped - 23 lines]
> > > Chris Hayes
> > > Still a beginner
Greg Maxey - 07 Mar 2007 20:13 GMT
I don't really know what to tell you other than the code posted on my
website works and your code is different.

Did you download the template and observe how it works?

> I have a catch:
>
[quoted text clipped - 57 lines]
>
> - Show quoted text -
CS Hayes - 07 Mar 2007 21:38 GMT
1) you have a great site, thanks for your service to our country

2) yes, The first example is from the site:

Sub UncheckIt()
****   oAutoTextUnchkBox.Insert Where:=Selection.Range****
End Sub

This line, marked by astericks, is freezing.

Signature

Chris Hayes
Still a beginner

> I don't really know what to tell you other than the code posted on my
> website works and your code is different.
[quoted text clipped - 62 lines]
> >
> > - Show quoted text -
Greg Maxey - 07 Mar 2007 21:56 GMT
Thanks. You are welcome.  That service, almost 30 years worth, ends in about
150 days ;-)

Oh you mean in the Toggle Objects.zip template.  I thought you were using
the Interactive Userform Checkboxes pages.

When you saying freezing, what does that mean?  Are you getting a runtime
error?  What does it say?

The AutoExec procdure in that template creates the relationship between the
AutoText entries and thier varialble names when Word executes (if the
ToggleObjects.dot file is in the start up directory).  Did you try stepping
through the AutoExec procedure to ensure the relationships where formed?

Signature

Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.

> 1) you have a great site, thanks for your service to our country
>
[quoted text clipped - 79 lines]
>> >
>> > - Show quoted text -
CS Hayes - 09 Mar 2007 14:01 GMT
I think where I'm getting lost is that I am using 2003 and the example is for
2007.  You have a page refferenced for 2003 but I can't tell where that ends
and I can resume with the code on the 2007 page.
Signature

Chris Hayes
Still a beginner

> Thanks. You are welcome.  That service, almost 30 years worth, ends in about
> 150 days ;-)
[quoted text clipped - 93 lines]
> >> >
> >> > - Show quoted text -
Lisa - 09 Mar 2007 14:59 GMT
Shouldn't that be oAutoTextUnchkBox.Insert Where Range :=
Selection.Range? Lisa
Lisa - 09 Mar 2007 15:03 GMT
Sorr, I meant this line:
ActiveDocument.AttachedTemplate.AutoTextEntries("CB").Insert
Where Range:=oRng
Greg Maxey - 09 Mar 2007 15:08 GMT
You didn't answer my questions.

Send me website feedback requesting contact (that will provide me your
valid e-mail address).  I will send yuo a .dot file that contains the
code and a working example.

> I think where I'm getting lost is that I am using 2003 and the example is for
> 2007.  You have a page refferenced for 2003 but I can't tell where that ends
[quoted text clipped - 112 lines]
>
> - Show quoted text -
CS Hayes - 09 Mar 2007 21:43 GMT
I'm not quite sure how to do "web site feedback" but my email is:
hayes.cs(remove this)@gmail.com

removing the (remove this)
Signature

Chris Hayes
Still a beginner

> You didn't answer my questions.
>
[quoted text clipped - 118 lines]
> >
> > - Show quoted text -
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.