Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

How to create TEXTBOX in Microsoft WORDs to accept data from VB6 Screen.

Hi there,

I have been asked to develop VB6 application to create User Interface screen to allow Human Resource Dept staff to input Employee data. When the COMMAND button is clicked then transfer to data to official WORDS documents (template) for printing. I don't know how to create TEXTBOX in WORDS document itself to receive the data transferred from VB6 screen. The User doesn't want to use Mail Merge facilities within WORDS itself.

Please help me out.

Enclosed are sample VB6 Interface Screen and WORDS document.
[558 byte] By [Lennie] at [2007-11-11 11:57:34]
# 1 Re: How to create TEXTBOX in Microsoft WORDs to accept data from VB6 Screen.
I would leave the textboxs on the VB6 screen.

You can add Bookmarks to the Word document, and dump the contents of your VB6 textbooks to individual bookmarks on the Word Template.
Hack at 2007-11-11 17:20:49 >
# 2 Re: How to create TEXTBOX in Microsoft WORDs to accept data from VB6 Screen.
Thanks Mr Hacky,
I am new to this and thanks for your suggestion and taking time off from your busy schedule to help me out. I will post the solution script to share it with others once I get it running
Lennie at 2007-11-11 17:21:50 >
# 3 Re: How to create TEXTBOX in Microsoft WORDs to accept data from VB6 Screen.
You are welcome and please do. :WAVE:
Hack at 2007-11-11 17:22:59 >
# 4 Re: How to create TEXTBOX in Microsoft WORDs to accept data from VB6 Screen.
Hi Hack and all,
As promised, I got my program running now using Mr Hack suggestion and examples obtained from other internet sites. Here are copy of my VB6 script.

Here are the steps to get it going.
WORDs Document.

1. determine the location in the WORD's document where you want to place the BookMark.
2. Click your cursor there and create the bookmark by selecting Menu/Insert/Bookmark.

dim oWord as Word.application
dim odoc as Word.documents

Private Function FGetIEAIndefinteTermToWord()
On Error GoTo Err_Word

Set oWord = New Word.Application
Set oDoc = oWord.Documents.Open(strDestination, , ReadOnly:=False)
oDoc.Activate

With oWord
FUpdateBookMark "bmFullName", txtFirstName.Text & " " & txtLastName.Text
FUpdateBookMark "bmFullName2", txtFirstName.Text & " " & txtLastName.Text
FUpdateBookMark "bmFullName3", txtFirstName.Text & " " & txtLastName.Text

FUpdateBookMark "bmPosition", txtPosition.Text
FUpdateBookMark "bmPosition2", txtPosition.Text
FUpdateBookMark "bmPosition3", txtPosition.Text

FUpdateBookMark "bmWorkLocation", txtWorkLocation.Text
FUpdateBookMark "bmAnnualSalary", Format(txtAnnualSalary.Text, "currency")
FUpdateBookMark "bmExpiryDate", strTempDate
FUpdateBookMark "bmagreementDate", Format(txtDateAgreed, "dd/mm/yyyy")
End With

oWord.Visible = True

Exit_Function:
Set oWord = Nothing
Set oDoc = Nothing
Exit Function

Err_Word:
MsgBox Err.Description
Resume Exit_Function

End Function

Private Function FUpdateBookMark(ByVal bm As String, itext As String)
Dim bmrange As Range
Set bmrange = ActiveDocument.Bookmarks(bm).Range
bmrange.Text = itext
End Function

Private Function FCopyFile()

'copy original copy
strSource = "F:\VB6Practice\VB6MailMerge\BigFile.doc"
strDestination = "F:\VB6Practice\VB6MailMerge\IEACopy.doc"
FileCopy strSource, strDestination
End FunctionHave fun.
Lennie at 2007-11-11 17:23:54 >
# 5 Re: How to create TEXTBOX in Microsoft WORDs to accept data from VB6 Screen.
I edited your post and added your code goes here tags as it makes reading code so much easier.

Thanks for sharing. I'm sure there will be others that will be grateful as well. :)
Hack at 2007-11-11 17:24:59 >