Replace MS Word quotes from string
Hi,
I'm using the following function to replace quote marks from a string into a format allowing storage into an Access database:
Code:
public function CleanQuotes( ByVal strDirty, boolRemove )
strData = Replace( Replace( strDirty, Chr(147), Chr(34) ), Chr(148), Chr(34) )
strData = Replace( Replace( strData, Chr(146), Chr(39) ), Chr(96), Chr(39) )
if not CBool( boolRemove ) then
strData = Replace( strData, Chr(39), String( 2, Chr(39) ) )
strData = Replace( strData, Chr(34), Chr(39) & Chr(34) )
elseif CBool( boolRemove ) then
strData = Replace( strData, Chr(39), Chr(32) )
strData = Replace( strData, Chr(34), Chr(32) )
do while InStr( 1, strData, String( 2, Chr(32) ) ) > 0
strData = Replace( strData, String( 2, Chr(32) ), Chr(32) )
loop
end if
CleanQuotes = Trim( strData )
end function
However, when quote marks are copied and pasted into the string, the quotes don't get replaced - hence throw an error with the database insert script.
Does anyone know how to prevent this?
Thanks very much...