Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

VB - Word Merge

Posted on 1999-06-21
3
Medium Priority
?
241 Views
Last Modified: 2010-05-02
I need to be able to generate word documents based on results generated in my VB app.  What is the quickest and best way to do this?
0
Comment
Question by:jimmy3
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 10

Expert Comment

by:viktornet
ID: 1518807
you mean DOC files?? not sure what your question is.. please explain further what your needs are... thank you!

..-=ViKtOr=-..
0
 

Accepted Solution

by:
abm earned 600 total points
ID: 1518808
The best way is to use the word as an active com server.
Reference the msword8 object library in your project and then use the methods and properties that this exposes to programitically create a word .doc

Here follows a very simple routine that creates a geniune. doc file and then saves the contents "Hello world"

This is the easiest solution I think but remember it is actually loading and saving from word an so has a performance overhead.

Private Sub Command1_Click()   ' Declare object variables for Microsoft Word,
   ' application and document objects
   Dim wdApp As Word.Application
   Dim wdDoc  As Word.Document

   ' Assign object references to the variables. Use
   ' Add methods to create new document   ' objects.
   Set wdApp = New Word.Application
   Set wdDoc = wdApp.Documents.Add
 
   ' Assign some text    ' Microsoft Word cells.
   wdDoc.Sentences(1).Text = "Hello World"
 
  'Save the doc
   wdDoc.SaveAs "c:\Temp.Doc"
   ' Close the Doc
   wdDoc.Close
   ' Close Microsoft Word with the Quit method.
   wdApp.Quit
   ' Release the objects.
   Set wdApp = Nothing
   Set wdDoc = Nothing
 
   
   End Sub
0
 

Author Comment

by:jimmy3
ID: 1518809
Thanks for the response.  However I still need some more info if you don't mind.  I need to merge the VB manipulated data with an existing MSWord template.  
Value1 in slot1 .... How do I reference the slots? (blocks where you enter text into a word template)  Can I name them in Word?  My need for knowledge is on the MSWord side.

Thanks again.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
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…
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

705 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