Solved

Transferring data directly into a Word document using VB

Posted on 2002-04-12
10
157 Views
Last Modified: 2010-05-02
I have a program which uses an Access database and I want to be able to "transfer" data from the database directly into the a new Word document after it has opened the program. I am fairly sure that this should be an easy thing to do and hopefully lots of you know the answer! Thanks in advance for all suggestions.

Cheers,

Colin.
0
Comment
Question by:cbitservices
  • 5
  • 4
10 Comments
 
LVL 1

Expert Comment

by:justinhemphill
ID: 6937456
You will need to use the Microsoft Word Object Library.  This is available as one of your references in VB.  Once you careate an instance of this, you will be able to create word documents.  This will give you the full functionality of Word itself.  You can record a macro in Word and then go back in and view it.  You can then use this code within VB to generate it.
0
 
LVL 1

Author Comment

by:cbitservices
ID: 6938657
Where can I get information on using the library? Thanks,

Colin.
0
 
LVL 16

Accepted Solution

by:
Richie_Simonetti earned 50 total points
ID: 6939577
You need to add a reference to microsoft word library, declare variables from it and work with object model.

Just a little example

dim wapp as word.application
dim wdoc as word.document

sub test
set wappnew word.application
set wdoc=wapp.documents.open("c:\mydoc.doc")
wapp.visible=true
end sub

and working from it.
0
 
LVL 1

Author Comment

by:cbitservices
ID: 6939775
OK, I now understand that I can use Word object library, but it would be helpful if anyone could tell me where to get the information on how to use it! Thanks,

Colin.
0
 
LVL 1

Author Comment

by:cbitservices
ID: 6940774
I have worked out some of the properties and methods but a reference would be handy; any ideas? Thanks,

Colin.
0
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 6941042
Well, what is your data?, where is saved? a recordeset?, directly from a table?
How do you want to populate word document?
0
 
LVL 1

Author Comment

by:cbitservices
ID: 6941403
Hi Richie,

I have already got it working to place data into the document from the database, etc., however, what I would like to know is whether there is a "Reference" anywhere for the methods and properties of the Word object, so that I could use the various facilities of the object more efficiently. If you know of such a thing please let me know. Thanks.

Regards,

Colin.
P.S. I will accept your comment as an answer and will post this as another question, so you will earn more points if you can help further. Thanks.
0
 
LVL 1

Author Comment

by:cbitservices
ID: 6941406
I need reference material on the Word object. I have posted another question for this.
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 6941980
you could see it at MSDN (on cd or microsoft site).
There is a bunch of resources at web. Just do a search in www.google.com with "word+com+visual+basic"
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 6941999
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

757 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

21 Experts available now in Live!

Get 1:1 Help Now