Outlook Form Data To Word Form Template

S

StacyR

I'm sending custom Outlook Form Data to a Word Form
Template through Visual Basic Script. All data transfers
to Word correctly with the exception of two fields. There
are two fields that utilize Chr(13)& Chr (10) or vbCRLF-
I've tried both methods and those fields transfer to the
Word template with the CR and LF being represented by
boxes. If those two Word fields are changed from form
fields to just bookmarks, with the corresponding VB code
changed to access the bookmarks, the CR and LF get
interpreted correctly. I really don't want to have to do
this, but is there any other work around? I've tried
doing the search for vbCRLF and replace with a ^p with VB
(based on KB article 274134), but I can't seem to get it
to work.

Thank you and regards.
 
S

Stacyr

Here is some of the code:
vClientAddress1=objPage.Controls("tClientAddress").Value
vClientCity=objPage.Controls("tClientCity").Value
vClientState=objPage.Controls("tClientState").Value
vClientZip=objPage.Controls("tClientZip").Value

Dim oApp
Dim ODoc
Set oApp = CreateObject("Word.Application")
oApp.Visible = True
oApp.WindowState = 1
Set ODoc=oApp.Documents.Add (reference to template
purposedly omitted from this email)
With oDoc
.FormFields
("bkClientAddress").Result=vClientAddress1 & (Chr(13) & Chr
(10)) & vClientCity & " " & vClientState & " " &
vClientZip

The rest of the Word document is set up as a form field-is
there no other way than to change to a bookmark?
Thank you.

Stacy
-----Original Message-----
You didn't show any code snippets, but my guess is that
you're setting form field values, right? For long text
strings and those containing vbCrLf, you need to set just
a bookmark, not a form field, and use the
Bookmark.InsertAfter method instead.
 
S

stacyr

Thank you for the reply. If I used bookmarks for these
two "problem" fields, I would need to turn off
protection. Also, we may want to use the Word form
template as a standalone document with the ability to
export the form data. If these were bookmarks, the
information wouldn't be exported with the rest of the form
data.

Thank you for the link. It looks like I need to make
changes like the following:
Change
vClientAddress1=objPage.Controls("tClientAddress").Value
To
vClientAddress1=Item.UserProperties("ClientAddress")
When the FieldName=ClientAddress and the Control
Name=tClientAddress. Is that correct?

Thank you and best regards.

Stacy
-----Original Message-----
Why are you set against using a bookmark, where needed,
when you know it works? An alternative would be to replace
the CR/LFs with spaces, which changes the way the data
looks. I don't think the ^p replacement technique works in
form fields (which are also subject to a 255-character
size limit), but feel free to try it. You can use the
Replace() function to change the value of vClientAddress1,
etc.
FYI, in general, you should be working with Outlook
property values, not control values, unless you have
unbound controls. See
http://www.outlookcode.com/d/propsyntax.htm
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top