View Single Post
  #2   Report Post  
Posted to microsoft.public.word.docmanagement
Jay Freedman Jay Freedman is offline
external usenet poster
 
Posts: 9,854
Default problem with CHR(13)&CHR(10) in bookmark

Although Word uses a Chr(13) character to represent a paragraph mark,
it isn't a "real" paragraph mark. (A paragraph mark is really an
object that contains formatting information, not just a simple
character or two.) Replace each occurrence in your code of

& Chr(13) & Chr(10) &

with

& vbCr &

and Word will interpret that as a "real" paragraph mark.

On Wed, 19 Sep 2007 21:58:44 -0400, "Keith G Hicks"
wrote:

My VBA code in MS Access inserts data from a query into bookmarks in a dot
file. I have a function that takes any # of address lines and stacks them
up. If there are 3 address fields for a customer in the table the function
takes into account that any one or more of them could be empty. For example:

AddressLine1 = "123 Main"
AddressLine2 = NULL
AddressLine3 = "Suite 1"
City = "Berkley"
State = "CA"
ZipCode = "91234"

The above gets concateneated like this:

CustAddress = AddressLine1 & Chr(13) & Chr(10) & AddressLine3 & Chr(13) &
Chr(10) & City & ", " & State & " " & ZipCode

The code in the function ignores AddressLine2 because it's empty. So the
resultant address in the query would be this:

123 Main
Suite 1
Berkley, CA 91234

and not this:

123 Main

Suite 1
Berkley, CA 91234

This works fine in MS Access. But when I post it to the word dot file as
follows:

.Item("CustAddress").Result = Nz(rs!CustAddress, "")

I end up with this on my document:

123 Main | | Suite 1 | | Berkley, CA 91234

where the 4 pipe characters are actually the little squares that appear when
a character is not in the font set.

I do not want to post the address lines separately to the template. I have
several other similar situations. What do I need to do to get this to work
correctly?

Thanks,

Keith


--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the newsgroup so all may benefit.