Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > VB How-To
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
VB How-To Ask your "How do I do this with VB?" questions in this forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB How-To section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old August 8th, 2003, 05:27 AM
Registered User
 
Join Date: Aug 2003
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Creating word tables, PLEASE help :D

Ok i have a little problem, i no how to draw a table into a word document from my VB application but i cant seem to get it to draw tables on the fly, i no its somthing silly im doing with the "range" at a guess, hope some one can help me, the following code is just a test but when i get it working ill be able to put it into practace.

Also any help on filling in the table and making the top row merg so that is only has one cell accross the table would be a big help

So it looks kinder like this

|-------------|
|------|------|
|------|------|
|------|------|
|------|------|

Dim oWord As Word.Application
Dim oDoc As Word.Document
Dim oRange As Word.Range


oWord = CreateObject("Word.Application")

oWord.Visible = True

oDoc = oWord.Documents.Add

Loop starts=====

oWord.Selection.Tables.Add(oDoc.Range, 4, 2)


Loop Ends =====



Reply With Quote
  #2 (permalink)  
Old December 1st, 2003, 08:31 AM
Registered User
 
Join Date: Nov 2003
Location: , , .
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Cadey,

Following is the code which fill a single row in the word template. Before running this example create a template and store it in a proper position (Word template). This template should carry a table with number of rows/columns with proper text (template text). In my example i've used ~First~ and ~Last~ words inside my table(row/cell). I am replacing that value with database value. U have got access to all word utilities thru vb.

I don't think is there any possiblity to create table from vb. Anyway try to do the same and let me know once u have acheived it.

Enjoy coding

Cheers
Prasanna



Dim mobjDoc As Word.Document
Dim con As ADODB.Connection
Dim res As New ADODB.Recordset
Dim strvalue As String
Dim rngRange As Word.Range


Dim objWordApp As Word.Application
mstrReportTemplate = "c:\Test\" & "MyDoc.doc"
Set mobjDoc = GetObject(mstrReportTemplate, "word.document")
mobjDoc.Activate
Documents.Open ("c:\Test\MyDoc.doc")
Documents("MyDoc.doc").Activate
Set con = CreateObject("ADODB.Connection")
con.Open "DSN=staples;UID=real_Dev;PWD=its"
res.CursorType = adOpenForwardOnly
res.ActiveConnection = con
res.Open "select co_tnt from res_site_Addl_inf where site_id='0031AZ'", con, , adLockOptimistic
While Not res.EOF
    strFirstName = res.Fields(0)
    strLastName = res.Fields(1)
    res.MoveNext
Wend
Set rngRange = mobjDoc.Tables(1).Cell(0, 0).Range
rngHeading.Find.Execute FindText:="~First~", ReplaceWith:=strFirstName
Set rngRange = mobjDoc.Tables(1).Cell(0, 1).Range
rngRange.Find.Execute FindText:="~AFTER~", ReplaceWith:=strLastName

....
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Word tables to access hayk_yer Access VBA 1 June 26th, 2007 10:49 AM
Creating word doc - word behaviour mat41 Classic ASP Professional 2 April 29th, 2007 06:46 PM
creating tables within tables in access??? carswelljr Access 3 August 23rd, 2006 01:21 PM
Help creating tables racin_vegas PHP How-To 1 January 19th, 2006 09:11 AM
Creating Reports in Word mckly VB Databases Basics 1 June 23rd, 2004 05:17 AM



All times are GMT -4. The time now is 08:57 AM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.