|
-
Aug 18th, 2004, 10:39 AM
#1
Thread Starter
Fanatic Member
Printing to word with a for loop
i have a program that prints to an MS word template. and it works perfect. the problem is this i have a list box in my app that i want to send all of the contents of the list box to the template i'm not so sure how i do this. i know that i will have to use a for loop(i think) but i was just wondering if some one could kinda point ina better direction.
"...Men will still say THIS was our finest hour"
If a tree falls in the woods and no one is there to see it, do all the other trees make fun of it?
-
Aug 18th, 2004, 12:57 PM
#2
Thread Starter
Fanatic Member
any one? can any one help me?
"...Men will still say THIS was our finest hour"
If a tree falls in the woods and no one is there to see it, do all the other trees make fun of it?
-
Aug 19th, 2004, 04:04 AM
#3
Can you do what you want with a single piece of text rather than a list?
post the code & I'll alter it for you.
-
Aug 19th, 2004, 07:09 AM
#4
Thread Starter
Fanatic Member
i actually got it to work, the problem is now getting to move to a new line. but this my code, just to show you how i did it.
VB Code:
Dim sql As String
Dim PT As New ADODB.Recordset
sql = "SELECT Toolnumber FROM Machines WHERE MachNum= '" & MachID & "'"
PT.Open sql, DBConn, adOpenDynamic, adLockOptimistic
Do While Not PT.EOF
appWd.ActiveDocument.Bookmarks("Tool").Select
appWd.Selection.Text = PT!ToolNumber & ", "
appWd.Selection.MoveDown wdLine, 1
appWd.Selection.MoveLeft wdCharacter, 2
PT.MoveNext
Loop
PT.Close
problem:
Exit Function
"...Men will still say THIS was our finest hour"
If a tree falls in the woods and no one is there to see it, do all the other trees make fun of it?
-
Aug 19th, 2004, 07:19 AM
#5
cool. well try this for the new line bit (should be slightly faster too):
VB Code:
...
Dim strTemp as String
appWd.ActiveDocument.Bookmarks("Tool").Select
strTemp = ""
Do While Not PT.EOF
strTemp = strTemp & PT!ToolNumber & ", " & vbCr
PT.MoveNext
Loop
appWd.Selection.Text = strTemp
...
I'm not sure if it is vbCr you need, if it isn't right try these instead:
vbCrLf
vbLf
-
Aug 19th, 2004, 07:27 AM
#6
Thread Starter
Fanatic Member
that worked thanx a whole bunch dude. you are the man.
"...Men will still say THIS was our finest hour"
If a tree falls in the woods and no one is there to see it, do all the other trees make fun of it?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|