Check Box code not working

S

Susan B. Quinn

I thought I had it worked out but it keeps coming up with an error when I run
my dialog box.

I have check boxes that I want the user to select to insert certain blocks
of text. There can be any combination of the six check boxes.

This is the abbreviated version of the code

Private Sub cmdok_Click()
' Insert information entered into the dialog box
' close dialog box and go to body of the letter to start typing


With ActiveDocument.AttachedTemplate

If chkb_ei.Value = True Then
..Bookmarks("ei_bm").Range.InsertAutoText ("EI_Assess")
End If

End With

If cb_pat = "four" Then
..Bookmarks("pp2_testpara").Range.InsertAutoText ("pp2_four_tests")
End If

End With

Unload frmbuilder
End Sub

It seemed to make logical sense but it keeps throwing me back to the code
with a 438 error message object doesn't support the property

Help would be appreciated. And advice on how to get a better understanding
of VB would be appreciated. I trawl the web but think I need to understand
what I am doing better.

Susan
 
H

Helmut Weber

Hi Susan,
With ActiveDocument.AttachedTemplate
If chkb_ei.Value = True Then
.Bookmarks("ei_bm").Range.InsertAutoText ("EI_Assess")
End If
End With

You are trying to insert an autotext entry
into the attached template.

You might want something like:
with activedocument
' ...
end with
 
S

Susan B. Quinn

Helmut isn't that what I have done?? I tried setting it up on each If
statement but that changed nothing.

I know that I have used the same code with command buttons and it works.

Completely lost Susan
 
T

Tony Jollans

Hi Completely lost Susan,

No, that isn't what you have done :)

This line ...

With ActiveDocument.AttachedTemplate

says work with the *Template*, when what you probably want is ...

With ActiveDocument

which says work with the *Document*.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top