Results 1 to 17 of 17

Thread: Inputting Values into Word

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Mar 2002
    Posts
    158

    Inputting Values into Word

    i am making a game and when a user inputs there username and complete the level they recive a certificate

    i want to know if it is possible to insert the username into the word document through VB

    the username is saved as a string

    is this possible

    thanks Trav

  2. #2
    Junior Member
    Join Date
    Aug 2001
    Posts
    19
    i do use word documents in my vb program. The places where i want to fill in my variable texts like name, etc i define in word a bookmark..
    in vb i make a connection with word (reference) and my document. Then i walk through all my bookmarks and replace them with te text i want...
    if this is what you'relooking for i can send you code for that!!

    greatings Ton

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Mar 2002
    Posts
    158
    YEAA THAT would be great if you could send it to me

    thanks heaps

  4. #4
    Junior Member
    Join Date
    Aug 2001
    Posts
    19
    try this.. !!
    just made a simple program for you because i don't have the sources right here.. this will work..
    do see the word document... do doubleclick on the formfields to see their propertys...like bookmarkname .etc...

    good luck

    Ton

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Mar 2002
    Posts
    158
    thanks heaps man thats exactly what i wanted
    thanks for making it for me

    is there a way you can put the vaLUE in a particualr spot

  6. #6
    Junior Member
    Join Date
    Aug 2001
    Posts
    19
    do use forms in the word document.. you can put wherever in your document the items as shown in the certificate document..if you doubleclick on the formfields there will be their propertys..do see what you can use like type, maximum lengt , Kapitals yes or no.. what do do leaving the formfield... there are many options.. also do try the others .. like combobox,selectbox etc...
    There are plenty of options to use Have FUN!!

    ton

  7. #7

    Thread Starter
    Addicted Member
    Join Date
    Mar 2002
    Posts
    158
    how do i open the word doc

    by locating it on the HD

    eg
    c:\windows\certificate.doc

    hwo do u do that

  8. #8

    Thread Starter
    Addicted Member
    Join Date
    Mar 2002
    Posts
    158
    and how do u add those filds into word

    i cant do it

  9. #9
    Junior Member
    Join Date
    Aug 2001
    Posts
    19
    do open the word document.. by clicking on the file i did send you...do see the attributes from this file if it's not read only.. (right mouse click on the file and then select propertys)
    if you open the file you will see the word document.. (or open any document you have in word...
    to use formfields do add a new toolbar..(from the mainmenu the 3th option (i dont know the name in english(i'm dutch). then do select adding toolbars.. you will see some are already selected.. do add now the toolbar making forms(in dutch formulieren)
    you will recognize the controls looks simular as the one from VB.. but less options.. Do select the controls what you use... and place them in your document.. Do change the attributes.by doubleclick the control...

    sorry i cannot make it more clear than this...
    do play a little with wordto figure out how word works!!

  10. #10
    Junior Member
    Join Date
    Aug 2001
    Posts
    19
    do use the attachment to seewhich options i do use..(sorry but it's a dutch version of word

  11. #11

    Thread Starter
    Addicted Member
    Join Date
    Mar 2002
    Posts
    158
    how dp i open the document from a set path on the HD?????

    i worked it all out besdies thaT

  12. #12
    Junior Member
    Join Date
    Aug 2001
    Posts
    19
    if hd means hard disc... do doubleclick on the file... will open automaticly... otherwise i don't know what u mean

  13. #13

    Thread Starter
    Addicted Member
    Join Date
    Mar 2002
    Posts
    158
    ok well i cant figure out how to do any of it

    any chance you cna make me another one

    and cna u make the word document located in c:\windows\certificate.doc

    and can u open it that way then

    i want the formfield to be username

    username is my variable for the persons name

    u could u could do that for me

  14. #14
    Junior Member
    Join Date
    Aug 2001
    Posts
    19
    in the vb sourcecode i do use app.path & "\certificate.doc"

    do put this document in the c:\windows\ directory and do change the app.path commando for

    "c:\windows\certificate.doc"

    app.path looks for the directory where you put you program.. so if you undo you zip file in the c:\windows directory everything works directly...

    sorry but i cannot help you more further if you send me the certificate.. i can change it for you so that the word document is ok!!
    ciao

  15. #15
    Fanatic Member SeaHag's Avatar
    Join Date
    Jul 2001
    Location
    Lake Huron
    Posts
    901
    Wheres the attachement


    Seahag

  16. #16
    Frenzied Member
    Join Date
    Jan 2001
    Location
    Newbury, UK
    Posts
    1,878
    You have dug up an old thread. Just in case you are wanting to do the same as the original asker, an alternative approach could be:

    Create a Word document with what you want in it.
    Put in it a "***marker***" for the users name.
    Save the document somewhere useful.
    Then use this code to change the marker to the actual name.
    VB Code:
    1. Option Explicit
    2. Private objWord As Word.Application
    3. Private wd As Word.Document
    4.  
    5. Private Sub Command1_Click()
    6.     If objWord Is Nothing Then
    7.         Set objWord = CreateObject("Word.Application")
    8.     Else
    9.         Set objWord = GetObject(, "Word.Application")
    10.     End If
    11.     DoEvents
    12.     Set wd = objWord.Documents.Open("c:\Test.doc")
    13.  
    14.     With wd.Content.Find
    15.         .Text = "***marker***"
    16.         .Replacement.Text = "ITS MY USERS NAME" & vbcrlf & "yet another line"
    17.         .Execute Replace:=wdReplaceAll, Forward:=True, Wrap:=wdFindContinue
    18.     End With
    19.     objWord.ActiveDocument.Save
    20.    
    21.     'objWord.Visible = True
    22.     If Not (wd Is Nothing) Then Set wd = Nothing
    23.     If Not (objWord Is Nothing) Then objWord.Application.Quit
    24.     If Not (objWord Is Nothing) Then Set objWord = Nothing
    25. End Sub

  17. #17
    Fanatic Member SeaHag's Avatar
    Join Date
    Jul 2001
    Location
    Lake Huron
    Posts
    901
    thnks

    Seahag

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