• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 375
  • Last Modified:

Checkbox response to formfield checkbox?

Hi All,

I have a VB form in a word document, when a command button is pressed i want the responses in the vb form to go onto another word document (not the one where the vb form is) i can get the command button to copy over the text strings onto a word form but i dont know how to do the checkboxes?

e.g. if chk_box 1 = true then word-doc bookmark checkbox 1 = true

any ideas?

Ive tried using activedocument but that doesnt seem to work as it still thinks im on the vbform document not the one thats been loaded up

Thanks in advance

Superblades
0
superblades
Asked:
superblades
  • 3
  • 3
1 Solution
 
irudykCommented:
The value of the checkbox form field in the Word document can be set using something like the following:
ActiveDocument.FormFields("Check1").CheckBox.Value=chk_box 1
In your case change "Check1" to whatever the bookmark name of your checkbox is.
0
 
superbladesAuthor Commented:
That doesnt seem to work

'the requested member of the collection does not exist' i presume this is because its looking for the check1 in doc1 when its in doc2?

0
 
irudykCommented:
Yep, that would be the case. So maybe try using somehting like:
Documents("doc2").FormFields("Check1").CheckBox.Value=True
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
superbladesAuthor Commented:
Hi, This is my code, it still doesnt seem to work :S

Private Sub CmdPrintSum_Click()
 Dim wdApp As New Word.Application
    Dim wdDoc As Word.Document
Set wdDoc = wdApp.Documents.Open("h:\memberssummary.doc")
   wdApp.Visible = True
   With wdDoc.Bookmarks
      .Item("member_name").Range.Text = txt_name
      .Item("member_name1").Range.Text = txt_name
      .Item("member_name2").Range.Text = txt_name
      .Item("add_line1").Range.Text = txt_add1
      .Item("add_line2").Range.Text = txt_add2
      .Item("add_line3").Range.Text = txt_add3
      .Item("city").Range.Text = txt_city
      .Item("post_code").Range.Text = txt_postcode
      .Item("contact_telno").Range.Text = txt_telno
      .Item("contact_email").Range.Text = txt_email
      .Item("enddate").Range.Text = txt_officeend
      .Item("member_name1").Range.Text = txt_name
      .Item("member_name2").Range.Text = txt_name
      .Item("add_line1").Range.Text = txt_add1
      .Item("add_line2").Range.Text = txt_add2
      .Item("add_line3").Range.Text = txt_add3
      .Item("city").Range.Text = txt_city
      .Item("post_code").Range.Text = txt_postcode
      .Item("contact_telno").Range.Text = txt_telno
      .Item("contact_email").Range.Text = txt_email
      .Item("enddate").Range.Text = txt_officeend
      '.Item("check5").
      End With
      Documents("h:\memberssummary.doc").FormFields("Check5").CheckBox.Value = opt_disYes
     
   Set wdDoc = Nothing
   Set wdApp = Nothing

End Sub
0
 
irudykCommented:
Okay you are using the object wdDoc to reference the Word document, so replace
Documents("h:\memberssummary.doc").FormFields("Check5").CheckBox.Value = opt_disYes
with
wdDoc.FormFields("Check5").CheckBox.Value = opt_disYes
0
 
superbladesAuthor Commented:
Brilliant!
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now