Automatic Generate a word-document from VB - Found a solution!!! 
Author Message
 Automatic Generate a word-document from VB - Found a solution!!!

I just found this on another site...  Here is how you do it!Hi Anh-Son,

Quote:
> I want to generate a document in Word-format from a progam implemented
> in VB.

Here is some very basic skeleton code that calls the Word object to get
you started.

  Dim wddoc As Word.Document

  On Error GoTo HandleErr

  Set wrd = CreateObject("Word.Application")

  wrd.Documents.Add

  'Functions to write some data to document  (nothin but text in a
table)
  'GenAddress
  'GenTable

  Set wddoc = wrd.ActiveDocument
  wddoc.Range.InsertAfter "this is a test"
  wddoc.SaveAs "d:\my Documents\vbtest.doc"
  wrd.Quit
  Set wddoc = Nothing
  Set wrd = Nothing
  Exit Sub

HandleErr:
  MsgBox "Error " & Err.Number & " " & Err.Description

End Sub

To find out how to create / insert / format whatever you need in Word, I
recommend you record some macros to get a start on the basic Word object
model syntax you need.

Cindy Meister
INTER-Solutions, Switzerland
http://www.*-*-*.com/

This reply is posted in the Newsgroup; please post any follow question
or reply in the newsgroup and not by e-mail :-)

----

Take it light!
Todd
****************************************************************************
***************************
*  Agendum Software ** Now offering 3 new tools FREE for Visual Basic
Programmers.  No nag screens, no cost and fully functional!   Visit our
WebSite today to download and check out our Spring 1999 commercial
releases! *
*
*  Click here for the Agendum Software Website
*  Web - http://www.*-*-*.com/

****************************************************************************
***************************



Quote:
> Please Help!
> I want to generate a document in Word-format from a progam implemented
> in VB. One friend of mine suggest me to use the RTF-format, but I think
> its better when I could directly generate it. There should be only some
> table, tilte, topline and bottomline in the document which come from a
> database as a report of query in the VB-program.
> Thanks,
> Son.



Thu, 31 May 2001 03:00:00 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. Automatic Generate a word-document from VB

2. Automatic Generate a word-document from VB

3. Automatic Generate a word-document from VB

4. Automatic Generate a word-document from VB

5. Automatic Generate a word-document from VB

6. Automatic Generate a word-document from VB

7. Automatic Generate a word-document from VB

8. Trouble Opening a Word Document with VB.NET,Open member not found in Documents

9. Generating word document files from embedded documents in Access or SQL Server DB.

10. Using VB.Net to Generate MS Word Documents

11. automatic printing word documents

12. Generating a word document from Excel

 

 
Powered by phpBB® Forum Software