Re: Replace function and carriage returns
- From: "Doug Robbins - Word MVP" <dkr@xxxxxxxxxxxxxxxxxx>
- Date: Sun, 8 Feb 2009 11:55:11 +1000
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
.
- References:
- RE: Replace function and carriage returns
- From: MikeT
- RE: Replace function and carriage returns
- Prev by Date: Re: Insert hyperlink
- Next by Date: Can VBA process autotext (quickparts) stored in the current docume
- Previous by thread: RE: Replace function and carriage returns
- Next by thread: Adding tables
- Index(es):
Relevant Pages
|