|
-
May 7th, 2001, 02:45 PM
#1
list box toword doc
Any ideas on how i an get the contents of listbox saved to a word document and have it saved as a seperate file each time for instance filename=date and time
-
May 8th, 2001, 02:28 AM
#2
Re: list box toword doc
This code does the job, you just need to add a refference to word (Microsoft Word 8.0 Type library) via the Project>Refferences menu.
The list is called List1
' Declare a word application and document
Dim wApp as new Word.Application
Dim wDoc as Word.Document
' show word (you can omit this if you want this to happen in the background)
wApp.Visible = true
' add a new document
set wDoc = wApp.Documents.Add
' write the contents of the list to the document
for t = 0 to List1.ListCount - 1
wDoc.Range().InsertAfter List1.List(t) & vbCrLf
next t
' save the document
' eg "C:\20010508092812.doc"
wDoc.SaveAs "C:\" & Format(Now(), "YYYYMMDDHHNNSS") & ".doc"
' clean up
wDoc.Close
set wDoc = nothing
wApp.Quit
set wApp = nothing
' we're done
Tom Cannaerts
[email protected]
Programming today is a race between software engineers striving to build bigger and better idot-proof programs, and the universe trying to produce bigger and better idiots. So far, the universe is winning -- Rich Cook
-
May 8th, 2001, 04:03 AM
#3
Re: list box toword doc
is this for embedded or linked document?
Just for my general knowledge.
-
May 8th, 2001, 04:18 AM
#4
Re: list box toword doc
worked great thank you and it is a linked doc. no need to answer.
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
|