PDA

View Full Version : Inserting Chr(4)



MacroShadow
02-08-2013, 02:47 AM
Hello all Experts,

I have a question that I was asked by I colleague and since I didn't have an answer I'm turning to the experts for help.

When using TypeText Chr(3) instead of inserting a line (footnote separator) it inserts a square box (or in other words a non printable character). Is there any way to insert the separator using vba (other than copy and paste (which does work))?

macropod
02-08-2013, 04:13 AM
Why are you trying to 'type' a footnote separator? Word inserts them as required when footnotes are inserted.

MacroShadow
02-08-2013, 04:18 AM
I don't have a clue as to what the reason is, to me it's just a question of curiosity, is it possible or not.

Chr(4) isn't the only one that won't 'type', the same is true for chr 1-7 and 16-31.

fumei
02-08-2013, 04:42 PM
Ummm, if you actually look up what those are, you will easily see that they are ALL non-printing "characters".

Chr(4) is neither a line, nor a footnote separator.

ASCII reserves the first 32 codes (numbers 0–31 decimal) for control characters: codes originally intended not to represent printable information, but rather to control devices (such as printers) that make use of ASCII, or to provide meta-information about data streams such as those stored on magnetic tape.

macropod
02-08-2013, 04:43 PM
I'm really not interested in "just a question of curiosity" and I can see no valid use for it.

The mere fact that Word uses certain characters as flags doesn't mean inserting those characters into a document will generate the attributes to which the flags relate. You cannot, for example, 'type' and opening or closing field brace, represented by ASCII 19 & 21, respectively.

fumei
02-08-2013, 04:46 PM
Really, I have to say that 5 seconds of a google search would have answered your question.

fumei
02-08-2013, 04:53 PM
Or perhaps you did not realie that Chr(x) means DEC of the ASCII table.

http://www.asciitable.com/

BTW: what on earth made you think that Chr(4) had anything to do with a line or a footnote separator

It is the End Of Transmission control character.

MacroShadow
02-09-2013, 09:56 AM
macropod,

Sorry for wasting your time. To me a question that if answered will add to my pool of knowledge, is important even if it may not have a practical application, but I guess that's just a philosophical difference between us.

fumei,

MsgBox AscW(Selection.Text) returns 4 when the footnote separator is selected. Thanks for the link.

fumei
02-09-2013, 01:25 PM
1. The link is not relevant for you in the context you mention. You used AscW which is UNICODE, not ASCII.

2. can you be more precise by what you mean by footnote separator

fumei
02-09-2013, 01:30 PM
And what makes you think that the 4 returned by AscW is the same as Chr(4).

MacroShadow
02-10-2013, 10:38 AM
The link is not relevant for you in the context you mention. You used AscW which is UNICODE, not ASCII.
Thank you, I missed that.


can you be more precise by what you mean by footnote separator
Sure. I mean the line that is inserted automatically by word to separate the main text from the footnotes, (3 is returned for the regular separator and 4 is returned for the continuation separator (if the footnote flows over to the next page).


And what makes you think that the 4 returned by AscW is the same as Chr(4).
I assumed (a dangerous habit) that the character code returned by AscW is the same as character code 4 in Chr(4).

fumei
02-10-2013, 01:26 PM
Yes, a dangerous assumption. In fact, an absolute fabrication.

What possessed you to use AscW() anyway, rather than Asc(). Just a random decision

MacroShadow
02-10-2013, 02:47 PM
So what is the number returned by AscW and Asc?

fumei
02-10-2013, 03:55 PM
You tell me. You say AscW returns 4. What does Asc return

fumei
02-10-2013, 10:40 PM
I have to say that you it would be better all round if you had a bit more of an experiential bent.

MacroShadow
02-10-2013, 10:56 PM
Thanks for your kind words...

MacroShadow
02-10-2013, 11:53 PM
Yes, a dangerous assumption. In fact, an absolute fabrication.
Now you got me really confused. I though you put me on the right track but Dec 4 from the ascii table is the EOT character, and so is Unicode decimal 4. As you can see: http://www.unicodemap.org/details/0x0004/index.html
In ASCII and Unicode, the character is encoded at U+0004 <control-0004>. (from Wikipedia).

fumei
02-11-2013, 07:50 PM
Perhaps a confusion about NUMBER versus meaning. And what on earth "track" are you on anyway. i think I am done here.

MacroShadow
02-11-2013, 08:35 PM
I'm sorry I really don't understand, but thanks for you willingness to spend so much time on this.

MacroShadow
02-13-2013, 11:38 PM
Is anyone else willing to help me?