Range object and Special char "à"

N

Neo

Hello All,

I am having char "à" in Word Doc. This something like comes as -->
when displayed in word. But when I use it through range.text I get "("

Anybody has idea why? and is there any work around to get actual chars
in range.text?

Best Regards,
Pravin A. Sable
 
D

Doug Robbins

I am not sure what you mean by "This something like comes as -->"

If I use

MsgBox Selection.Range.Text

and the selection includes a word with "à" in it, then the text in the
message box displays the "à" correctly.

--
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
Hello All,

I am having char "à" in Word Doc. This something like comes as -->
when displayed in word. But when I use it through range.text I get "("

Anybody has idea why? and is there any work around to get actual chars
in range.text?

Best Regards,
Pravin A. Sable
 
H

Helmut Weber

Hi Doug,

I guess, there is a character from a decorative font in the range.

But right now this is all I can contribute to a solution,
unless scanning all of the range for decorative characters
remember their font and position in the range and applying
the formatting again, after e.g. inserting the range's text
somewhere else in the doc.

Greetings from Bavaria, Germany

Helmut Weber, MVP
"red.sys" & chr(64) & "t-online.de"
Word XP, Win 98
http://word.mvps.org/
 
P

Pravin A. Sable

Hello Helmut,

You are right, it is decorative char.

I have kept file at
http://www.ccs.neu.edu/home/pravin/Doc1.doc

If you run marco junk inside, which prints content. You will see only "(".

This is very un-expected.

I am thinking on your suggestion to check every character but I have one
more quick and dirty alternative.

Copy range and paste as text in another temp document. You will be surprised
when pasted as text it convert decorative form of "-->" char to "à". This is
acceptable to me, since I used replace function letter to get rid of "à". But
I just can't replace "(". That is very common char!

I was thinking Range object is very useful, but now I am extracting text
from Range objects and very frustrated.

Please do let me know if you have any solution for this.

Thanks for your time,
Pravin A. Sable
 
H

Helmut Weber

Hi Pravin,

I don't know exactly what you want to do.

There would be a lot to say on fonts (and ranges).
However, this character is Wingdings 224.
It gets transferred correctly into a new empty document
when using formattedtext. Like this:

Dim r As Range
Set r = Documents("doc1.doc").Range.FormattedText
Documents("xdok3.doc").Range.FormattedText = r

However, within the same doc, this doesn't seem to work.

When "a" with accent grave is displayed, the information
on font was lost or is disregarded and character 224
of an ordinary font is displayed. Which might be the second
byte of character information.

A messagebox and a range seems to use only the first byte,
with might be character 40 "(" in case of decorative fonts.

But you see, my knowledge in this particular case is limited,
and I'd rather not post more vague ideas or speculations.

Greetings from Bavaria, Germany

Helmut Weber, MVP
"red.sys" & chr(64) & "t-online.de"
Word XP, Win 98
http://word.mvps.org/




Greetings from Bavaria, Germany

Helmut Weber, MVP
"red.sys" & chr(64) & "t-online.de"
Word XP, Win 98
http://word.mvps.org/
 
P

Pravin A. Sable

Hello Helmut,

Thanks a lot for your reply. And I would appreciate any input (even if it is
vague).

This is my objective:

I want to read word document and insert that text information into
ClearQuest Oracle Databse. ClearQuest doesn't accept anything except
US-ASCII. Hence I replace any non US-ASCII chars. So, I am happy if I get
something like "à". But I would hate to see it getting converted into "(".
Which is happening in Range.Text.

Your solution is useful, if transfer is between two word docs. But, I am
working with Word Doc and Oracle Databse (that too using clearQuest APIs not
ADO or DAO).


Now, hopefully, I have made problem clear, and people might have some
suggestations.

Thanks a lot.
-Pravin A. Sable
 
H

Helmut Weber

Hi Pravin,

first I'd reset all of the doc to some harmless font
like Arial. Then, I think, there is no way but checking
each individual character. Like this:

Dim c As Range
Selection.WholeStory
Selection.Font.Name = "Arial"
Selection.Collapse
Set d = Dialogs(wdDialogInsertSymbol)
For Each c In ActiveDocument.Range.Characters
c.Select
d.Update
If d.Font <> "(normaler Text)" Then
MsgBox "gotcha"
' do what you like to this character
End If
Next

Note: "(normaler Text)" is the german version.
Could be something like "(standard text)" or "(ordinary text)"
or "(normal text)"
I don't know. I hate localizations.

Greetings from Bavaria, Germany

Helmut Weber, MVP
"red.sys" & chr(64) & "t-online.de"
Word XP, Win 98
http://word.mvps.org/
 
H

Helmut Weber

---
To those who don't know that the sample doc
is really very small, of course one can process
a range instead of the whole doc.

Greetings from Bavaria, Germany

Helmut Weber, MVP
"red.sys" & chr(64) & "t-online.de"
Word XP, Win 98
http://word.mvps.org/
 
N

Neo

Hello Helmut,

I am had lot of trouble while getting text from Range object as it is.
At First, I had to struggle with numbering format and then with special
chars. Although both the things get solved by copy/paste. So, I copy
range into clipboard and get it back through DataObject. This gives me
text in format which I can handle before inserting into database.

Your solution is more elegent but I am not sure how many more places, I
am going to struggle while getting text from range. Also, I niether
want to change existing file, nor want to make copy of it.

How about this...


r As Range
set r = ThisDocument.Range 'or whatever one want

Dim dataobj As New DataObject
If r.Text = "" Then
GoTo exit function
End If
r.Copy
dataobj.GetFromClipboard
output = dataobj.GetText


This is quite simple but as of now effective. Let me know your thoughts
on this.

Thanks
Pravin

P.S.

for getting Range.Text numbering I worte following, that combine with
yours code is too much code for just getting text from range.


Dim para As Paragraph
Dim paras As Paragraphs

Set paras = r.Paragraphs

Dim i As Integer
i = 1
Do While i <= paras.Count
Set para = paras(i)
Dim sLine As String
sLine = para.Range.Text
If para.Range.ListFormat.ListString <> "" Then
sLine = para.Range.ListFormat.ListString & " " & sLine
End If
If sLine <> "" Then
If getRangeNumbedText1 <> "" Then
getRangeNumbedText1 = getRangeNumbedText1 & vbCr &
sLine
Else
getRangeNumbedText1 = sLine
End If
End If
i = i + 1
Loop
Set paras = Nothing
Set para = Nothing
 
H

Helmut Weber

Hi Pravin,

as long as your solution isn't made for end users
who might wonder why there is something different
from what they expect in the clipboard,
I'd say it is alright.

Greetings from Bavaria, Germany
Helmut Weber, MVP
"red.sys" & chr(64) & "t-online.de"
Word 2002, Windows 2000
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top