|
-
July 16th, 2001, 02:29 PM
#1
Creating Word documents from within VB
Hi there,
I 'd like to know if it is possible to create a word document from within Visual Basic, without starting MS Word itself, e.g. by using the Word Object library?!?
I want to create a new document, put text in it, not displaying any of this to the user and then save it to a .doc file.
Please help!
greetz Law
-
July 16th, 2001, 03:21 PM
#2
Re: Creating Word documents from within VB
Hello,
The only way I know of is to create a series of rtf statements and then write them to a file with a .doc extension. The file will then load.
The big problem is that rtf files are extremely difficult to create manually. My advice to you would be to create a blank rtf document to use as a template, which will contain all of the start and end information. Each new line in the document must start with a /par statement but I advise you to read up on the subject if you wish to do anything more complex as some of the commands are arcane to say the least.
Once you have the statements stored in the array or whatever it is simply necessary to write them in the same order as they were created to the .doc file. All the new statements should be inserted before the last one as this closes the document.
Hope this helps
Andrew
-
July 16th, 2001, 06:39 PM
#3
Re: Creating Word documents from within VB
Actually, A .rtf file can be easily be created using the RichTextBox control.
Just enter your text and images into it and then use its SaveFile method. It will create all the Html stuff for you.
John G
-
July 16th, 2001, 06:44 PM
#4
Re: Creating Word documents from within VB
Here is one example already posted in this forum. You might search this forum for other examples.
I found this one by going to "SEARCH' keying in "Word Document" and hitting the search button.
'
http://63.236.73.79/cgi-bin/bbs/wt/s...age=0&Limit=25
John G
-
July 16th, 2001, 06:51 PM
#5
Re: Creating Word documents from within VB
Try this:
First go under project | References, and check Microsoft Scripting Runtime (scrrun.dll)
Dim tex as Filesystemobject
Dim b
b = Freefile
set tex = new Filesystemobject
tex.createtextfile "C:\My Documents\mydocfile.doc"
Open "C:\My Documents\mydocfile.doc" for output as b
print #b, mytext.text
Close b
HTH
--Ant
--------------------------------------------------
check out my newest freeware
E-mail me at: [email protected]
for the address
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
|