Re: Replace function and carriage returns

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



By "second row of the destination table" do you mean the second (next)
record in the table?

To do that, you would need to add a new record (or index to the next record)
and then write the data to the appropriate field in that record.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

"MikeT" <MikeT@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:BF65B5F1-BDB1-4348-A875-EBEEC3BFEBB1@xxxxxxxxxxxxxxxx
To: Steven M

Hi Steven,

I am working on an issue that is indirectly related to Bz's issue. I am
trying to import the contents of a .txt file into an MS Access table
through
VBA. The file is pipe delimited, and I have been able to successfully
place
the delimited values into their corresponding fields within the first row
of
the destination table. What I cannot figure out is how to take the last
value of the first row, which contains the carriage return, and begin
populating the second row of the destination table with the values to the
immediate right of the carriage return.

Any thoughts?

Regards,

Mike



"StevenM" wrote:

To: Bz,

Perhaps you need something like:

'****
'*
'* Function: StripCr
'*
'* When a string ends with a "Carriage Return" marker, or a "Carriage
Return"
'* and "Line Feed" markers, this function will strip them off from a
string.
'*
'****
Function StripCr(ByVal sStr As String) As String
Dim nPos As Long
nPos = InStr(sStr, Chr(13))
If nPos > 0 Then
sStr = Left(sStr, nPos - 1)
End If
StripCr = sStr
End Function

Steven Craig Miller

"bz" wrote:

I am using Word 2000 and XP.

I have a table containing formfields. In a macro I output the contents
of
selected formfields to a text file and then later insert this file into
a new
Word document and use the text to table conversion to create a table.
Sometimes, if one of the formfields contains carriage returns, the
result is
that the text following the carriage return begins on the first column
of the
next row (i.e. not the next line in the same cell).

The best solution would be to have the carriage returns work correctly
(within the same cell).

An alternative is to strip out the carriage returns. I tried doing
this
using the Replace function. Before writing out to the text file, I
copy the
.result of the formfield to a string
(myString=ActiveDocument.FormFields("myString").Result).
I then try to replace: myString=Replace(myString,"^p",""). Also tried
with
myString=Replace(myString,Chr(13),"").

The result is that no replacement is made. This is the case no matter
what
I try to use as a replacement string.

Thanks in advance for any help, bz


.



Relevant Pages

  • forward host her lovely protection
    ... their destination, the faces they met grew sadder and sadder. ... everywhere she heard them murmur: "Napoleon is dead! ... Napoleon is dead!" ... And again the people around her carriage murmured, ...
    (sci.crypt)
  • Re: trouble with string replace
    ... string literal, when it looks like what you wanted was a regular expression literal. ... Although - replace - will convert string arguments into regular expression literal it will use the string as the pattern that will be matched, so will be trying to match something that ends - /g -, which isn't going to be a carriage return. ... The values returned by - innerHTML - are a serialisation of the the DOM, and DOMs represent as post HTML parsing interpretation of a document. ... Series of whitespace characters can act as a single white space character or thay can be ignored completely. ...
    (comp.lang.javascript)
  • Re: string functions
    ... sometimes it might have more than one carriage return like it is shown in your example. ... So, your display of the starting string and the result you wanted clearly showed a starting sring with spaces and a result with carriage returns, or a series of individual values, quite the opposite of what you have just asked for in this new message of yours. ... The next job the code does is to analyze that string in a small loop and display the Ascii code of each character in a listBox, together with the character each of those Ascii codes represents. ...
    (microsoft.public.vb.general.discussion)
  • better precede goodss now or Catherine will daily diminish them in response to you
    ... their destination, the faces they met grew sadder and sadder. ... everywhere she heard them murmur: "Napoleon is dead! ... Napoleon is dead!" ... And again the people around her carriage murmured, ...
    (sci.crypt)
  • Re: can I split a C string
    ... Actually I am writing portable code that runs on windows & ARM9. ... the string on console window(here "\r" is not ... the carriage from right to left, the designers split the task into two - ... paper up a line - so that it would require two input characters to do this ...
    (comp.lang.c)