Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can you invoke "Word formating" in a text box control?

Status
Not open for further replies.

crowsario

Programmer
Jul 23, 2001
24
US
Hi all,

I'm trying to create an interface for users to type up a form letter that will save to a database. I am using a text box control with the multiline property set to true. (i can change this control if you think I should use something different). The tabs save and as long as the user writes their paragraph with out hitting enter (one long line of text, kind of like notepad) I can print this letter to a word doc with no problems. However if return is pressed the formatting will be messed up when printed to Word. The other problem is the user can not view the full line of text when using the interface.

What I am envisioning is for the "long line of text" to basically be broken up so the user can view all lines of text the way it would be printed in Word. I tried counting the number of characters but with Word some characters are bigger than others so each line can have a different number of columns depending on the number of capital letters, or W's rather than i's (just as an example).

Is this possible with a textbox control? If so please help?
If not, should i use another control?

Oh and "No" they can not just type up a Word doc, I need to store the text in a table for manipulation (Basically, a Mail Merge without using Word's Mail Merge functionality, too many problems with different versions of office)

Thanks again
-Crow
 
My users use Word '97 and Word 2000 with no problem because I use Late Binding and stick to Word '97 features. If you compiled your VB for release with AS OBJECT instead of AS WORD.APLLICATION, WORD.DOCUMENT etc, and you used CreatObject (or GetObject) instead of NEW, you should have had no problems. In testing, you can use AS WORD.APPLICATION in order to get Intellisense but compile AS OBJECT for release with.
Code:
#IF blnTesting then
    Private objWord as Word.Application
    Private objDoc as Word.Document
#Else
    Private objWord as Object
    Private objDoc as Object
#End if
Set objWord = CreateObject("Word.Application")
Go to Project / Properties / Make / Conditional Compilation Arguments and enter blnTesting = -1:
You can use any Word OLB references to get constants etc. Then look into the Rich Text Box for your fomatting.
 
Thanks for the post JohnYingling. I have tried this and unfortunately for me, my users use 97, 2000, and 2002. In order to make 2002 work like 97 you have to add a line of code that will throw errors with 97 and 2000 (according to microsoft). Also, with Word 2002 you can not use Union Queries to perform a mail merge. Again...unfortunatley for me all of the letters they will need to generate (about 40 of them) deal with Union Queries.

Thanks Anyway
-Crow
 
Sorry. Don't know "Union Queries". I gather all the data needed to open a new bank account in VB then pass the data to a Public Method of VBA inside a "dummy" word Doc which then controls the formatting and printing of signature cards, New Account Letters etc. using DocVariables (Insert / Field /Document Automation / DocVariable). In effect, I hand over all the data, a hundred or so variables in a Scripting.Dictionary, then tell the documents to print themeselves.
 
Crow,
If you need to include mail merge functionality within VB then look at TX Text control, details can be found at I've used this control to create a highly sophisticated direct mail package, but with a few lines of code you can use it for storing all sorts of formatted (Word compatable) text. Using a control like this may save you hours of work trying to manipulate the standard VB control and of course does not rely on all your users having office.

Nick W
 
Well Duhlbert,

If I did that it would have been too easy. I would have been already finished and could have been worrying about some other part of my program.

So yep, you got me... I'm a moron. Sometimes I wonder about myself. :p

Thanks a ton
-Crow
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top