Consulting

Results 1 to 4 of 4

Thread: Word and Access CR Issue

  1. #1
    VBAX Contributor
    Joined
    Jun 2014
    Posts
    107
    Location

    Word and Access CR Issue

    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?

  2. #2
    Knowledge Base Approver VBAX Guru macropod's Avatar
    Joined
    Jul 2008
    Posts
    4,435
    Location
    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.
    Cheers
    Paul Edstein
    [Fmr MS MVP - Word]

  3. #3
    VBAX Contributor
    Joined
    Jun 2014
    Posts
    107
    Location
    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).

  4. #4
    Knowledge Base Approver VBAX Guru macropod's Avatar
    Joined
    Jul 2008
    Posts
    4,435
    Location
    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.
    Cheers
    Paul Edstein
    [Fmr MS MVP - Word]

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •