通过VBA的挂锁符号 [英] Padlock symbol through vba

查看:58
本文介绍了通过VBA的挂锁符号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以通过 Chr() ChrW()或类似的方式通过VBA在单元格中打印挂锁符号(打开和关闭)?

Is it possible to print a padlock symbol (open & closed) in a cell with Chr(), ChrW() or something similar through VBA?

推荐答案

似乎Excel将特殊字符存储为UTF-16.只要您拥有适合16位的代码,就很容易:只需使用函数 ChrW 转换代码.例如,闹钟的代码为U + 23F0,因此您可以编写 ActiveCell.Value = ChrW(& H23F0),然后您会得到闹钟(前缀& H定义一个十六进制数字.

It seems that Excel stores special chars as UTF-16. As long as you have a code that fits within 16bit, it's easy: Just convert the code using function ChrW. For example, the code for an alarm clock is U+23F0, so you can write ActiveCell.Value = ChrW(&H23F0) and you get your alarm clock (the prefix &H defines a hexadecimal number).

但是,当您遇到的字符不适合这16位时,您必须弄清楚UTF-16代码并将其连接起来.我发现的锁是 U + 1F512 U + 1F513 ,它们的UTF-16代表分别是0xD83D 0xDD12.0xD83D 0xDD13.所以你写类似

However, when you have characters that doesn't fit into these 16bit, you have to figure out the UTF-16 codes and concatenate them. The locks I found are U+1F512 and U+1F513, and their UTF-16 representatives are 0xD83D 0xDD12 resp. 0xD83D 0xDD13. So you write something like

ActiveCell.Value = ChrW(&HD83D) & ChrW(&HDD12)

当然,您需要为支持这些字符的单元格设置一种字体.

Of course, you need to set a font to the cell that supports these characters.

我发现 http://www.fileformat.info/info/unicode/char/search.htm 有助于查找匹配的字符.如果您已经有一个字符并且可以将其粘贴到单元格中,则可以使用我在此答案中编写的代码: https://stackoverflow.com/a/55418901/7599798

I found http://www.fileformat.info/info/unicode/char/search.htm helpfull to find matching characters. If you have already a character and you can paste it into a cell, you can use the code I've written in this answer: https://stackoverflow.com/a/55418901/7599798

这篇关于通过VBA的挂锁符号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆