.doc from Visual Basic 
Author Message
 .doc from Visual Basic

Hi there!

I have a question about creating word-files from a VB-application. The
.txt file that we know how to generate from VB looks terrible. The
application data will be taken into word and processed here. My question
is of course what is the best way to do this. Does anyone know about
some component that creates a word-file from VB, or can I generate an
RTF-file or some other format that preserves my formattings. If this is
not possible, does anyone have the experience how complicated macro I
have to write to make word formatting my .txt file.

I would be very happy if I got some response to my question.

Regards

Michael Martinsson
Ericcson Microwave Systems AB



Fri, 30 Jun 2000 03:00:00 GMT  
 .doc from Visual Basic

If you know that Word will be installed where you are running your program,
you can use it to write the Word file.  Depending on whether you have Word 6
or Office 97, you can use either:

    CreateObject("Word.Basic") or
    CreateObject("Word.Application")

These will return objects that enable you to create documents in word and
command it to write them in any format you like.  If you can't use Word, you
might want to look for another editor with OLE Automation support that can
write RTF files.  Personally, I wouldn't try to do it myself.

Tom

Quote:

> Hi there!

> I have a question about creating word-files from a VB-application. The
> .txt file that we know how to generate from VB looks terrible. The
> application data will be taken into word and processed here. My question
> is of course what is the best way to do this. Does anyone know about
> some component that creates a word-file from VB, or can I generate an
> RTF-file or some other format that preserves my formattings. If this is
> not possible, does anyone have the experience how complicated macro I
> have to write to make word formatting my .txt file.

> I would be very happy if I got some response to my question.

> Regards

> Michael Martinsson
> Ericcson Microwave Systems AB



Sat, 01 Jul 2000 03:00:00 GMT  
 .doc from Visual Basic

1.. you have to create templates in word for the formatting in
headers/footers/paper size, etc
2. open word from vb
3. from vb write code to send output to simple text file
4. create a new document in word from vb using the above template
5. in the open/new document event of the template itself you have to write
code to perform text placement,formating HERE YOU WILL PICK UP THE TEXT
FROM THE SIMPLE TEXT FILE YOU CREATED
Phew !! this is not as simple as it seems
lots of hard work here
do you need a sample if yes then write me direct and i will send you one

best regards,
manish dighe
(network admin & vb/sql server developer)



Quote:
> Hi there!

> I have a question about creating word-files from a VB-application. The
> .txt file that we know how to generate from VB looks terrible. The
> application data will be taken into word and processed here. My question
> is of course what is the best way to do this. Does anyone know about
> some component that creates a word-file from VB, or can I generate an
> RTF-file or some other format that preserves my formattings. If this is
> not possible, does anyone have the experience how complicated macro I
> have to write to make word formatting my .txt file.

> I would be very happy if I got some response to my question.

> Regards

> Michael Martinsson
> Ericcson Microwave Systems AB



Tue, 04 Jul 2000 03:00:00 GMT  
 .doc from Visual Basic

Quote:
>> I have a question about creating word-files from a VB-application. The
>> .txt file that we know how to generate from VB looks terrible. The
>> application data will be taken into word and processed here. My question
>> is of course what is the best way to do this. ...................

There is a simple way to do this:

Create a Document in WORD and create all the Paragraph-Formats you need.
Create one Paragraph with each format and insert here a text like "Paragraph
1"..."Par 3"...
Save the Document as .RTF - File

Now open this .RTF-File with some pure text editor.
All you need is the preamble WORD creates for you.
Then you can insert all the variable text using the paragraph-preambles (you
have some examples in your file - all those "Paragraph 1"...
then put the End-sequence into the new file and voila - thats it.

best regards

-------------------------------
Rainer Pietsch

-------------------------------



Fri, 07 Jul 2000 03:00:00 GMT  
 .doc from Visual Basic

Well, I've tried both approaches. From my experience using Word 97,
using the CreateObject("Word.Application") is by far the best way to
go. You can lift large portions of code from Word just by running the
macro recorder to find out how to format particular text. It took me
about 2 to 3 hours to generate documents with headings with variable
spacing before and after them, indented paragraphs, bullet lists,
headers and footers etc. By contrast, going the RTF route is a real
nightmare, particularly if you use Word 97 to generate the RTF as a
model -- verbose is one  word that springs to mind. To generate the
same documents reliably by writing the RTF directly took me several
days (and would likely take several days more if I wanted differently
formatted documents). For simple formatting, compare RTF from Word 97
and that for the same document from something like WordPad. It's a
revelation. If you must use Word to access some particular
functionality, use the earliest version available.

Writing out a text file, and reading it into a template you've created
(as was suggested earlier in this thread) sounds far too much like
hard work to me, and of course, if your users delete the template,
you're in deep trouble...

Of course, producing documents that look good, whether via RTF or by
directly creating them, does depend on having some skill at document
layout and formatting, but that's a rather different topic.

Quote:

>>> I have a question about creating word-files from a VB-application. The
>>> .txt file that we know how to generate from VB looks terrible. The
>>> application data will be taken into word and processed here. My question
>>> is of course what is the best way to do this. ...................

>There is a simple way to do this:

>Create a Document in WORD and create all the Paragraph-Formats you need.
>Create one Paragraph with each format and insert here a text like "Paragraph
>1"..."Par 3"...
>Save the Document as .RTF - File

>Now open this .RTF-File with some pure text editor.
>All you need is the preamble WORD creates for you.
>Then you can insert all the variable text using the paragraph-preambles (you
>have some examples in your file - all those "Paragraph 1"...
>then put the End-sequence into the new file and voila - thats it.

>best regards

>-------------------------------
>Rainer Pietsch

>-------------------------------

--
Dr Tony Gillie
IT Consultancy, Programming, and Desktop Publishing Services

PGP Key ID 54B4E689, Fingerprint E61CA9B811188727 4AFC4B12B7E00B4B


Sun, 09 Jul 2000 03:00:00 GMT  
 .doc from Visual Basic

If you are familiar with html mark-up, you should find rtf mark-up
reasonably simple.  Create a file with wordPad and save as rtf, then open it
in notepad to view code.   For info on rtf syntax also have a look at the
help file that comes with helpworkshop.  by writing your own rtf code, you
do not have to include a richtextbox control (and associated ocx).

Quote:

>Hi there!

>I have a question about creating word-files from a VB-application. The
>.txt file that we know how to generate from VB looks terrible. The
>application data will be taken into word and processed here. My question
>is of course what is the best way to do this. Does anyone know about
>some component that creates a word-file from VB, or can I generate an
>RTF-file or some other format that preserves my formattings. If this is
>not possible, does anyone have the experience how complicated macro I
>have to write to make word formatting my .txt file.

>I would be very happy if I got some response to my question.

>Regards

>Michael Martinsson
>Ericcson Microwave Systems AB



Mon, 10 Jul 2000 03:00:00 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. How to create Word doc from Visual Basic

2. do Visual Basic 6.0 and Visual Basic .NET version beta Working Both

3. Difference between Visual Basic 6 and Visual Basic.Net

4. Visual basic 4 to Visual basic 6

5. Visual Basic 3.0 to Visual Basic 6.0

6. Visual Basic 5 vs. Visual Basic 6

7. Visual basic programs - connect to a server - Visual Basic 5 Enterprice Edition

8. loading visual basic 3.0 applications in visual basic 5.0

9. Learning Basic - Visual Basic - Visual InterDev

10. Visual Basic 3.0 vs Visual Basic 4.0

11. Microsoft Visual Basic v3.0 Professional/Microsoft Visual Basic Assistant v3

12. Looking for differences between Visual Basic 5.0 enterprise and Visual Basic 5.0 Profesional

 

 
Powered by phpBB® Forum Software