Solved

Filling out a MS Word Template with VB6

Posted on 2004-04-22
3
1,236 Views
Last Modified: 2008-03-03
I have a Word Template that contains several textboxes on it (txt_Name, txt_Birthdate, etc.).  I want VB to open the template and fill in the textboxes with values from my program.  I got the template open but I am stuck on how to change the text of the textboxes.  Thanks in advance for the help.
0
Comment
Question by:jmwheeler
  • 2
3 Comments
 
LVL 2

Accepted Solution

by:
sbennetts earned 100 total points
ID: 10889316
You could insert bookmarks into each of the text boxes and then use the following code to enter the data at the correct location...

oApp.Documents.Open myFileName, , True
oApp.Visible = False
'Find the 'bookmark' and add mytext
oApp.Documents(1).Bookmarks(myBookMarkName).Select
oApp.Selection.TypeText myText

Simon
0
 
LVL 11

Author Comment

by:jmwheeler
ID: 10889389
This might work, does anyone have a solution that would allow me to do this without adding a bunch of bookmarks?
0
 
LVL 2

Expert Comment

by:sbennetts
ID: 10889494
You can use the
oApp.Documents(1).fields property, but I'm not 100% sure of the syntax involved...
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

919 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now