Results 1 to 2 of 2

Thread: vb variable to word

  1. #1

    Thread Starter
    Junior Member
    Join Date
    May 2001
    Posts
    16

    vb variable to word

    I capture the users results in vb. I want to take what the user entered and pass it to word. It consist of text boxes and check boxes. I created them on the word document using the form tools. This is word 97 using vb6. Is there a way to take my vb variable and pass it to word such as

    Dim ObjWord as Word.Application
    set ObjWord = new Word.Application
    objWord.ActiveDocument ("TheNameOfBoxInTheWordDoc") = VariableInVB.

    Is there somewhere that contains what the methods and properties of the word object are and how they work. I can't find anyplace that seems to have a good description of the stuff. any help would be great. Thanks

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333
    VB Code:
    1. 'this should give you the general idea
    2. Dim WordObject As Word.Application
    3. Set WordObject = CreateObject("Word.Application")
    4.  
    5.      With WordObject
    6.      .Documents.Open ("c:\program files\qcap\transmove.doc")
    7.      .ActiveDocument.Bookmarks("transtype").Select
    8.      ' reapply the boomark name to the selection
    9.      '.ActiveDocument.Bookmarks.Add Name:="First",Range:=Selection.Range
    10.      .ActiveDocument.Bookmarks("fromlocation").Select
    11.      .Selection.Text = (lblMoveFrom.Caption)
    12.      .ActiveDocument.Bookmarks("tolocation").Select
    13.      .Selection.Text = (lblMoveTo.Caption)
    14.      .ActiveDocument.Bookmarks("numbers").Select
    15.      .Selection.Text = (txtStatus.Text)
    16.      .ActiveDocument.Bookmarks("preparedby").Select
    17.      .Selection.Text = (UCase(UserAccount))
    18.      .ActiveDocument.Bookmarks("comments").Select
    19.      .Selection.Text = (txtComments.Text)
    20.      .ActiveDocument.Bookmarks("movedate").Select
    21.      .Selection.Text = (Today)
    22.     End With
    23.    WordObject.Visible = False
    24.        WordObject.ActiveDocument.PrintOut Background:=False
    25.        WordObject.ActiveDocument.SaveAs FileName:="x.doc"
    26.        ' setting the printing to background will display the document
    27.        ' on the screen while it is being printed
    28.        ' WordObject.Documents.Close '("c:\program files\qcap\transmove.doc")
    29.     WordObject.Application.Documents.Close
    30.     Set WordObject = Nothing

Posting Permissions

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



Click Here to Expand Forum to Full Width