Please, help me out here... string handling? 
Author Message
 Please, help me out here... string handling?

[Repost]

Hi everybody,

I'm writing some macro code that takes a selected piece of text in a word
document and then passes this on to a COM object written in C++. The problem
is that the string, when it shows up in the de{*filter*} of C++, looks messy...
it has double pipes (vertical bars ||) where it is supposed to be a newline
character. So when I perform my operation in C++ code (translating the
selected text) and return the new translated text I get an extra new line in
the Word document for each newline sent to my translation function.

Is there a way to strip a selected text in Word so that it only contains
pure ascii characters? And of course making it possible to reverse the flow
so that strings will look ok when putting them back to the word document?

I really need this to get working!

Thx,

/Tommy



Tue, 12 Oct 2004 18:07:29 GMT  
 Please, help me out here... string handling?
Hej Tommy

I'm sure you're aware of the Asc function in VBA. I also guess that you'll
not be able to define which characters are permitted one as you are dealing
with Swedish, English and possibly other languages each with certain
characters.

Would it be possible to
- define certain characters to look for,
- convert them into some character
- make the com object is neglected them and
- revert back when the com object is done

Sub testar()
Dim sString As String
Dim i As Long
Dim iLen As Long

sString = Selection.Range
iLen = Len(sString)

For i = 1 To iLen
    Select Case Mid(sString, i, 1)
        Case vbCr
            sString = Left(sString, i - 1) & "" & Mid(sString, i + 1)
        Case vbCrLf
            sString = Left(sString, i - 1) & "#" & Mid(sString, i + 1)
        Case Else
    End If
Next

'after cleaning the string, call the com-obj
'revert the process
End Sub

--
/Anna Bohman
Bra Utbildning AB, Sweden

http://www.*-*-*.com/
-------------------------------------------------------------------------



Quote:
> [Repost]

> Hi everybody,

> I'm writing some macro code that takes a selected piece of text in a word
> document and then passes this on to a COM object written in C++. The
problem
> is that the string, when it shows up in the de{*filter*} of C++, looks
messy...
> it has double pipes (vertical bars ||) where it is supposed to be a
newline
> character. So when I perform my operation in C++ code (translating the
> selected text) and return the new translated text I get an extra new line
in
> the Word document for each newline sent to my translation function.

> Is there a way to strip a selected text in Word so that it only contains
> pure ascii characters? And of course making it possible to reverse the
flow
> so that strings will look ok when putting them back to the word document?

> I really need this to get working!

> Thx,

> /Tommy



Tue, 12 Oct 2004 18:35:21 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. How to handle print outs in VB?

2. how to handle NULL values from a FORM when using date string functions - help please

3. how to handle NULL values from a FORM when using date string functions - help please

4. PLEASE HELP, PLEASE HELP, PLEASE HELP, PLEASE HELP, PLEASE HELP, PLEASE HELP, PLEASE HELP,

5. Need help with time outs

6. Help:How do you de-reference handles in 32-bit VB4--Please Help

7. Can anyone HELP me PLEASE PLEASE PLEASE PLEASE PLEASE PLEASE PLEASE PLEASE PLEASE

8. PLEASE HELP PLEASE HELP PLEASE HELP

9. A little help please............ File handling and moving

10. Device Context Handle - PLEASE HELP

11. Handling Files - Please Help

12. Help please, how to handle long files names in vb3

 

 
Powered by phpBB® Forum Software