Results 1 to 6 of 6
  1. #1
    New Lounger
    Join Date
    Mar 2004
    Location
    Knoxville, Tennessee, USA
    Posts
    24
    Thanks
    0
    Thanked 0 Times in 0 Posts

    VB6/Word Question (VB6)

    I need to transfer the value of CheckBox1 in a VB6 form to CheckBox1 in a Word document which has been opened from a template. I have placed the checkbox into the template. I am proficient at inserting information from textboxes from a VB6 Form into a Word Document. I simpy cannot transfer the value between checkboxes as stated above. Any help would be greatly appreciated. Thank you!

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: VB6/Word Question (VB6)

    What kind of check box have you placed in the Word template? From the Forms toolbar or from the Control Toolbox?

  3. #3
    New Lounger
    Join Date
    Mar 2004
    Location
    Knoxville, Tennessee, USA
    Posts
    24
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: VB6/Word Question (VB6)

    It was on the Control Tool Box

    Thanks!

    Bob

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: VB6/Word Question (VB6)

    If the check box is inline with the text:

    Dim blnValue As Boolean
    blnValue = ...
    objDoc.InlineShapes(1).OLEFormat.Object.Value = blnValue

    If it is floating, change InlineShapes to Shapes.

    In the above, objDoc is a variable of type Word.Document. You can also use objWord.ActiveDocument, where objWord is a variable of type Word.Application. The code assumes that the check box is the first inline shape (or shape) in the document, adapt as needed.

  5. #5
    New Lounger
    Join Date
    Mar 2004
    Location
    Knoxville, Tennessee, USA
    Posts
    24
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: VB6/Word Question (VB6)

    Hans:

    Thank you for your reply. Unfortunately, I am not very well-versed in VB Code. Could you illustrate how the code would look if both the form and Word checkboxes was named CheckBox1? Thank you!

    Bob

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: VB6/Word Question (VB6)

    Assuming the code runs in the VB6 form, for example in the On Click event of a command button:

    Private Sub cmdTransfer_Click()
    Dim wrdApp As Object
    Dim wrdDoc As Object
    Set wrdApp = CreateObject("Word.Application")
    Set wrdDoc = wrdApp.Documents.Open("MyDocument.doc")
    wrdDoc.CheckBox1.Value = Me.CheckBox1.Value
    wrdDoc.Close SaveChanges:=True
    wrdApp.Quit
    Set wrdDoc = Nothing
    Set wrdApp = Nothing
    End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •