Computing.Net > Forums > Office Software > Inserting info to word doc with VBA

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Inserting info to word doc with VBA

Reply to Message Icon

Name: BlueScreenOD
Date: November 18, 2005 at 05:59:45 Pacific
OS: Win XP pro
CPU/Ram: 3.2 ghz p4 / 1 GB DDR
Comment:

I use a thin client program at my work called WRQ which has VBA built into it. I'm attempted to scrape information off of my screen and place it into a word document.

I've figured out how to add simple text to a word doc by using the code:

Dim Word As Word.Application
Set Word = CreateObject("Word.Application")

Word.Visible = True
Word.Documents.Add
Word.Selection.TypeText Text:="baaaah"

But i'm having trouble trying to figure out how to add information into a templated word doc. I have a form that looks like this:

Name of Claimant: ___________
Date of Accident: ___________

And I want to add the infmation where the underscored line is. Does anyone know how this is done? I'm not to familiar with VBA, and i'm kind of learning as I go.



Sponsored Link
Ads by Google

Response Number 1
Name: StuartS
Date: November 18, 2005 at 16:52:30 Pacific
Reply:

I found that the search and replace functions using Word with Visual Basis a bit cumbersome and a little on the slow side.

The solution I used was to use an RTF file as a template. Load the template file into an RTF control. Use the RTF search and replace functions to insert the information. Save the file as and RTF file then load it into Word and save it as a DOC file.

You will of course be restricted to the formatting facilities available to RTF.

One advantage of this method is that you are not restricted to a particular version of Word. I am using a function that was originally designed to run with Office 97. It is still running unaltered with Office 2003.

In this instance it is using information extracted from an Access database to generate a Word DOC.

Stuart


0
Reply to Message Icon

Related Posts

See More


Any Outlook / IMAP expert... Office Outlook mail folde...



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Office Software Forum Home


Sponsored links

Ads by Google


Results for: Inserting info to word doc with VBA

From Word 2003 to Word 2000 www.computing.net/answers/office/from-word-2003-to-word-2000/4415.html

Setting up word doc - template? www.computing.net/answers/office/setting-up-word-doc-template/8245.html

how to link excel to word and word to excel www.computing.net/answers/office/how-to-link-excel-to-word-and-word-to-excel-/8898.html