PDA

View Full Version : Word and Access CR Issue



heedaf
12-21-2017, 01:34 PM
I have an application where all the heading titles in a Word document are placed in an Access table. Occasionally I need to go back and compare the two to see if anything has changed. The process works great except for CR (carriage return - ASC = 13) which is sometimes included or not included in the Access table. Can anyone tell me how Access will determine if a the CR is included or not included when the Word heading title is pasted in the table?

macropod
12-21-2017, 09:15 PM
Why not ensure the CR is always excluded; quite simply done using Split. For example:
StrHeading = Split(StrHeading, vbCr)(0)
where StrHeading is the heading text. Regardless of whether it starts out with the CR, the above line will return the string without it.

If you start out by cleaning up your Access data using code like the above, you can then compare the cleaned data against the Word headings, which you clean in the same way.

heedaf
12-22-2017, 09:37 AM
Thank you. I was just curios as to why the CR was included or not included since the title was retrieved using the same method (oHdr.paragraph(1).range.text).

macropod
12-22-2017, 04:29 PM
A code line like:
oHdr.paragraph(1).range.text
will include the terminating paragraph break. It might be that, if that terminating paragraph break is formatted as hidden text or as a Style Separator, it won't be added to Access. Either way, the approach I suggested will eliminate all terminating paragraph breaks.