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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Outlook98 - Copying Text Fields To Word Template

Status
Not open for further replies.

SHardy

Programmer
May 9, 2001
231
GB
I have an Outlook98 application that uses a custom form (based on a task item).

I have added a print function that opens a Word template and copies all the form's field values to the Word fields.

On the whole it seems to work OK. However, there is one problem I am getting that could be a bit of a drawback. The text fields within the Word template are defined as "Maximum Length = Unlimited". In Outlook, when I assign a text field's value to a variable there is no problem. But when I then try to assign that variable value to the word field I'm getting a "String too long" error if the field contains more than 255 characters.

I am using the following syntax to copy to the word document:

oWordDoc.FormFields("ChangeDetails").Result = ofChangeDetails

The custom fields in Outlook accept more than 255 characters, and the Word fields should accept more than 255 characters, so why will it not copy a large string from one to the other?

How can I do this?
 
I have got around this problem. For the fields that are likely to contain more than 255 characters, rather than inserting the field values into Word form fields, I am inserting them at bookmarks instead.

However, this has now presented another problem. I have formatted my Word document in such a way that I have the field names on the left, with the field contents to the right. If a field contains a carriage return, then the following line is not kept in alignment with the rest. Instead it is aligned to the far left of the page.

I have experimented with adding a function to search for all Chr(13) and replace with Chr(10), but to no avail.

Any ideas how I can solve this problem (other than reconsidering the format of my document)?

Thanks
 
I have just gone for the option of re-designing my Word template in such a way as to make sure that this isn't a problem.

I would still be interested if anyone knows how to answer the above though.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top