|
-
Jul 2nd, 2002, 12:56 AM
#1
Thread Starter
Addicted Member
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
-
Jul 2nd, 2002, 01:32 AM
#2
Junior Member
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
-
Jul 2nd, 2002, 01:56 AM
#3
Thread Starter
Addicted Member
YEAA THAT would be great if you could send it to me
thanks heaps
-
Jul 2nd, 2002, 03:31 AM
#4
Junior Member
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
-
Jul 2nd, 2002, 03:35 AM
#5
Thread Starter
Addicted Member
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
-
Jul 2nd, 2002, 04:12 AM
#6
Junior Member
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
-
Jul 2nd, 2002, 04:46 AM
#7
Thread Starter
Addicted Member
how do i open the word doc
by locating it on the HD
eg
c:\windows\certificate.doc
hwo do u do that
-
Jul 2nd, 2002, 05:01 AM
#8
Thread Starter
Addicted Member
and how do u add those filds into word
i cant do it
-
Jul 2nd, 2002, 05:16 AM
#9
Junior Member
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!!
-
Jul 2nd, 2002, 05:31 AM
#10
Junior Member
do use the attachment to seewhich options i do use..(sorry but it's a dutch version of word
-
Jul 2nd, 2002, 05:40 AM
#11
Thread Starter
Addicted Member
how dp i open the document from a set path on the HD?????
i worked it all out besdies thaT
-
Jul 2nd, 2002, 05:50 AM
#12
Junior Member
if hd means hard disc... do doubleclick on the file... will open automaticly... otherwise i don't know what u mean
-
Jul 2nd, 2002, 06:05 AM
#13
Thread Starter
Addicted Member
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
-
Jul 2nd, 2002, 08:01 AM
#14
Junior Member
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
-
Oct 21st, 2002, 08:57 AM
#15
Fanatic Member
Wheres the attachement
Seahag
-
Oct 21st, 2002, 09:37 AM
#16
Frenzied Member
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:
Option Explicit
Private objWord As Word.Application
Private wd As Word.Document
Private Sub Command1_Click()
If objWord Is Nothing Then
Set objWord = CreateObject("Word.Application")
Else
Set objWord = GetObject(, "Word.Application")
End If
DoEvents
Set wd = objWord.Documents.Open("c:\Test.doc")
With wd.Content.Find
.Text = "***marker***"
.Replacement.Text = "ITS MY USERS NAME" & vbcrlf & "yet another line"
.Execute Replace:=wdReplaceAll, Forward:=True, Wrap:=wdFindContinue
End With
objWord.ActiveDocument.Save
'objWord.Visible = True
If Not (wd Is Nothing) Then Set wd = Nothing
If Not (objWord Is Nothing) Then objWord.Application.Quit
If Not (objWord Is Nothing) Then Set objWord = Nothing
End Sub
-
Oct 21st, 2002, 09:40 AM
#17
Fanatic Member
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|