VB 6.0 - Export 2 table to MS Word problem - Asked By Ralph Acido on 31-Jan-06 08:45 PM

Helo everyone can i ask you something.. Im developing an Grading system.. I want to display the records of two into MS Word... how is that? does anyone know what is the solution for this? please need your help...

Here are fields..

from Table Students:

            IDNUM, lname, fname, mname, section, yearlevel, etc...

from my Grades table:

           IDNUM, yearlevel, school_yr,subject, Grade1,grade2,grade3,grade4,remarks

and when you export to MS Word it looks like this (with table and borders):

          05-0001 - Acido, Ralph A.

           Year Level   School Year  Subject     G1    G2       G3     G4  Remarks
                 I           2006-2007    English      89    70        80     87   81.5

inserting table into word object - Asked By Venkat K on 01-Feb-06 05:17 AM

Dim oWord As Word.Application
    Dim oDoc As Word.Document
    Dim oTable As Word.Table
    Dim Pos as Double

  'Start Word and open the document template.
    Set oWord = CreateObject("Word.Application")
    oWord.Visible = True
    Set oDoc = oWord.Documents.Add

  'Insert a 3 x 5 table, fill it with data and make the first row
    Dim r As Integer, c As Integer
    Set oTable = oDoc.Tables.Add(oDoc.Bookmarks("\endofdoc").Range, 3, 5)
    oTable.Range.ParagraphFormat.SpaceAfter = 6
    For r = 1 To 3
        For c = 1 To 5
            oTable.Cell(r, c).Range.Text = "r" & r & "c" & c  'Give the field names here
    oTable.Rows(1).Range.Font.Bold = True
    oTable.Rows(1).Range.Font.Italic = True

Export 2 table to MS Word - Asked By John Conway on 01-Feb-06 09:47 PM

The easiest way I've found to do this is to:
1. Add a DataEnvironment and Create a Child Command for your 2nd Table 
2. Add a DataReport. 
3. Add the Fields you want to export to your datarepot. 
4. Add a comand button on your form to view the datareport. The Datareport has Export and Print capability. Choose Export and choose where you want to save the document.
5. Now----- for the FileName you'll need to type .doc as your extension-- Also where you seeSave As Type--- You'll need to select Text(.txt) otherwise it will save as HTML. 6. Now when you open up your document you just exported you may get prompt saying--. Either the feature you' selected does not support this or has not been used and would you like to install it--- Choose No.
7. You now have a MSWord of your 2 tables. 
8. To keep from see the prompt (described in #6) just choose save as ---- Go to Save As Type as choose Word Document.  
9. You''ll need to experiment a bit with the layout on your Datareport.  
It had taken me 4/5 times to get a satisfactory result ... or was it 10.. . haha. Anyway. I think it's the easiest way to get the result you're looking for. 
Note: Don't forget about the .doc extension and Text(txt) at the end of your filename when exporting.

What about in MS Excel? - Asked By Ralph Acido on 01-Feb-06 11:39 PM

thank you very much.. it really works.. how about i ant ot export this one in an MS Excel.. any idea sir? thank you again...
MS Excel - Asked By John Conway on 02-Feb-06 01:38 AM
1. Do the same thing as in the previous example but use the Excel extension .xls

OR-----For better results

2. Use a spreasheet from components (MIcrosoft office Web Components 11.0) Right click on the spreadsheet and choose Command and Options. Choose Datasource and set the Sheet DataSource (Edit) like you would for an Adodc control. Once you do that just go to the properties window and set the DataSource agaiin. The data will automatically fill.