VBE and Unicode

K

KevinR

Hi
I have a macro that changes one group of weird characters to another.
Now that there is unicode, I want to edit the macro so that the 2nd
set of weird characters is a set of unicode characters.

But when I paste or otherwise try and input a unicode character, I get
"?". Is it possible that MS hasn't made the macro editor unicode
aware? If so, amazing, and, what do I do?

Thanks
Kevin
 
M

matt neuburg

KevinR said:
Hi
I have a macro that changes one group of weird characters to another.
Now that there is unicode, I want to edit the macro so that the 2nd
set of weird characters is a set of unicode characters.

But when I paste or otherwise try and input a unicode character, I get
"?". Is it possible that MS hasn't made the macro editor unicode
aware? If so, amazing, and, what do I do?

Doesn't chr() work? m.
 
J

John McGhie

Hi Kevin:

It is "certain" that string operations in the Visual Basic for Applications
are NOT Unicode-enabled. It's not the editor that's the problem, it's VBA
itself: it can't manipulate double-byte strings natively.

The really bad news is that this is because Microsoft wants VBA to go away
(as does a lot of the industry). VBA was designed when people were nice and
computers were not connected to the Internet. In today's toxic
virus-infested network soup, VBA cannot be made sufficiently secure, due to
the way it was designed.

Microsoft is attempting to replace VBA with VB dot-Net. I won't go into it
here except to say that it's a "much better idea". It is secure by design,
and much richer and more powerful than VBA was.

Now, the really really bad news is that Microsoft has "no plans" to migrate
..Net to its Office:Mac platform. And what that really means is they
actually have detailed plans, including costings, and they are waiting for
there to be sufficient interest in .Net solutions development on the Mac to
warrant the cost of the transition.

Given that the cost involved would probably exceed the cost of building
Office for the Mac, I think .Net on the Mac is unlikely in the foreseeable
future.

However, if you ask Paul Berkowitz, who inhabits this newsgroup, he would
tell you all about AppleScript. AppleScript is here now and Office-wide on
the Mac. I am sure the AppleScript compiler is Unicode-enabled. Paul will
tell us whether it will (easily) do Unicode operations in Word.

AppleScript in MS Office Mac is a little bit of a "work in progress". Most
of it is there, but there are some limitations where the AppleScript is
effectively calling in to the Word executable using the same API as VBA
uses, so things that are not possible in VBA are not necessarily possible in
AppleScript.

Hi
I have a macro that changes one group of weird characters to another.
Now that there is unicode, I want to edit the macro so that the 2nd
set of weird characters is a set of unicode characters.

But when I paste or otherwise try and input a unicode character, I get
"?". Is it possible that MS hasn't made the macro editor unicode
aware? If so, amazing, and, what do I do?

Thanks
Kevin

--

Please reply to the newsgroup to maintain the thread. Please do not email
me unless I ask you to.

John McGhie <[email protected]>
Consultant Technical Writer
Sydney, Australia +61 4 1209 1410
 
P

Paul Berkowitz

However, if you ask Paul Berkowitz, who inhabits this newsgroup, he would
tell you all about AppleScript. AppleScript is here now and Office-wide on
the Mac. I am sure the AppleScript compiler is Unicode-enabled. Paul will
tell us whether it will (easily) do Unicode operations in Word.

Here I am.

Yes, Word's AppleScript is fully Unicode. Every text value is actually
Unicode text. (Unfortunately, the AppleScript compiler can't compile Unicode
characters inserted into current script editors even though Script Editor
2.0 lets you insert the characters correctly. That will change.) Any Unicode
in a Word document, a text file written in UTF-16, or brought in via a
variable from elsewhere (e.g. Entourage) will work, and can also be
incorporated _into_ a Word doc.
AppleScript in MS Office Mac is a little bit of a "work in progress". Most
of it is there, but there are some limitations where the AppleScript is
effectively calling in to the Word executable using the same API as VBA
uses, so things that are not possible in VBA are not necessarily possible in
AppleScript.

True. But text seems to be OK.

First make a new Entourage contact.

Copy the following text (no quotes):

ザ ã㪠ƀƢ Ä£ ΠЖФ

and paste it into the "Last Name" field of this contact. (This contains
Katakana, Hiragana, Latin Extended B and A, Greek, and Cyrillic characters.)
Save and Close.

Open Entourage's Address Book. Select this contact in Entourage's Address
Book. (You'll find it wit all the characters intact at the end of your
Address Book.)

Now run this script in Script Editor:


tell app "Microsoft Entourage"
set theContact to item 1 of (get selection)
set aVariable to last name of theContact
end tell

tell application "Microsoft Word"
set aDoc to make new document
type text selection text aVariable
end tell


All the characters transcribe perfectly. Word substitutes fonts as needed to
get all the characters.(The Japanese characters are in some Asian font
ending Pro W3 the Latin Extended B in Lucida Grande, and the rest in Times
New Roman, my default Normal font.)

--
Paul Berkowitz
MVP MacOffice
Entourage FAQ Page: <http://www.entourage.mvps.org/faq/index.html>
AppleScripts for Entourage: <http://macscripter.net/scriptbuilders/>

Please "Reply To Newsgroup" to reply to this message. Emails will be
ignored.

PLEASE always state which version of Microsoft Office you are using -
**2004**, X or 2001. It's often impossible to answer your questions
otherwise.
 

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