Jump to content
Chinese-Forums
  • Sign Up

Calling IMEs from VBA script


Recommended Posts

Posted (edited)

Admin Note: Moved from this thread to prevent it going off-topic

it seems that setting the default font to MS Arial Unicode for both English and Chinese fixes this problem at least for Pinyinput.

Also, "(Use Asian text font)" seems to work.

My question, if you know, is how to call pinyinput from a word vba script.

Edited by imron
Posted

I'm not sure I know what you mean. Pinyinput is just an input method. What parts of it are you trying to call? If you wanted to convert pinyin with numbers to pinyin with tones from within VBA, you'd probably have to write your own VBA script to do that.

Posted

I was just thinking that if I could invoke Pinyinput (cause it to execute or run) from a VBA script, then I might be able to incorporate it into macros to do useful things more easily, without resorting to a long winded VBA script to do the same thing that Pinyinput already does more seamlessly and elegantly.

One simple way of invoking Pinyinput from a macro would be through emulating a keystroke (non-mouse) sequence, if it exists, such as, say, “alt-p”. Is there a way of assigning “alt-p” to bring up Pinyinput? If so, then that would be a good start. Next, the hard part is how to pass a string to Pinyinput, such as, “Ni3 hao3 shi4jie4” and have Pinyinput process it into “Nǐ hǎo shìjiè”. From an initial try at it, I’ve found that manually bringing up Pinyinput and then running, “Selection.TypeText Text:="Ni3 hao3 shi4jie4" will not pass the string to Pinyinput, so getting the script to communicate with Pinyinput needs to be worked out. After that, then the final trick is to programmatically switch back to the English IME.

Another thing I was thinking about is clicking a toolbar button and having it invoke both Pinyinput and Word’s “find” function together; i.e., one click brings up both. Then the user (me) could type pinyin into Pinyinput within the “Find” dialog, click “Find Next” and it would find the pinyin in my document. When I close the “Find” dialog, then the script will programmatically switch back to the English IME. This is easier than all the mouse clicks it takes to do this manually.

Those are just some examples of how Pinyinput could be useful in Word macros. If it’s possible to do these things with Pinyinput then it would be great. If not, then I’ll try to work up the enthusiasm to use the old Word macro for converting tones numbers into tone marks and incorporating it into larger functions.

Posted (edited)

This might be totally useless answer since i don't have the pinyininput, but i'm guessing it is no different for other IME's, so you can use API's to change it, like shown here.

Also i think you can assign ctrl+shift+some character to change directly to certain IME's, not sure if using sendkeys triggers the change, but if not then probably using postmessage should work.

Edited by BaoMiHua
typos

Join the conversation

You can post now and select your username and password later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Click here to reply. Select text to quote.

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...