用VBA将焦点定位于名称框
时间:2023-05-31 22:13:12
Excel中提供了许多快捷键,但遗憾的是没有提供一个快捷键可以将焦点定位与名称框,下面的宏代码就可以实现这个功能。
Public Declare Function SetFocus Lib "user32" (ByVal hwnd As Long) As Long
Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" _
(ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Public Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" _
(ByVal hWnd1 As Long, ByVal hWnd2 As Long, _
ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
Sub SetFocusNameBox()
Dim Res As Long
Res = SetFocus( _
FindWindowEx( _
FindWindowEx( _
FindWindow("XLMAIN", Application.Caption) _
, 0, "EXCEL;", vbNullString) _
, 0, "combobox", vbNullString))
End Sub
我们可以给这个宏代码指定一个快捷键,如Ctrl+Shift+N,方法如下:
单击菜单“工具→宏→宏”,打开“宏”对话框,选择“SetFocusNameBox”,单击“选项”按钮,在其中的文本框中输入大写的“N”,单击确定。
以后,只要按快捷键Ctrl+Shift+N,就可以将焦点定位到名称框
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
怎么连接两段光纤?光纤快速连接器的使用方法
![](https://img.aspxhome.com/file/2023/3/a297475_0s.jpg)
chrome浏览器二维码识别生成方法图解教程
![](https://img.aspxhome.com/file/2023/9/a342307_0s.jpg)
IOS16怎么更新?IOS16更新教程
![](https://img.aspxhome.com/file/2023/6/a323648_0s.jpg)
Excel工作薄错误提示颜色怎么设置?
![](https://img.aspxhome.com/file/2023/0/40210_0s.png)
MAC怎么快速切换输入法?MAC输入法切换快捷键
![](https://img.aspxhome.com/file/2023/6/a215956_0s.jpg)
WinXP系统打不开CHM文件的快速解决办法
![](https://img.aspxhome.com/file/2023/28/a244255_0s.jpg)
Win10系统怎么显示文件扩展名?
![](https://img.aspxhome.com/file/2023/5/a314008_0s.png)
excel中right函数的运用方法
win7硬件加速在哪里?win7电脑硬件加上怎么开启?
![](https://img.aspxhome.com/file/2023/1/a271990_0s.png)
Win7启动IE浏览器就会自动打开两个主页的解决方案
![](https://img.aspxhome.com/file/2023/27/a232431_0s.jpg)
Excel XNPV 函数 使用教程
![](https://img.aspxhome.com/file/2023/2/a163332_0s.png)
kswebshield.exe文件分析及进程占用CPU过高原因
如何使用in相机重影功能 in相机中的重影功能使用方法
![](https://img.aspxhome.com/file/2023/8/a335530_0s.jpg)
如何转移Windows7系统C盘的用户文件夹
![](https://img.aspxhome.com/file/2023/29/a256717_0s.jpg)
用户反馈Win10 1903显卡存在兼容问题导致屏幕失真
![](https://img.aspxhome.com/file/2023/4/a308023_0s.png)
WinXP系统连接网络打印机教程
![](https://img.aspxhome.com/file/2023/1/a273145_0s.jpg)
Win8升级Win8.1报错0x80004003的原因
![](https://img.aspxhome.com/file/2023/2/a288653_0s.jpg)
百度音乐怎么设置背景界面 百度音乐设置背景界面方法
![](https://img.aspxhome.com/file/2023/8/a339022_0s.jpg)
神舟G8怎么用u盘装win10系统?
![](https://img.aspxhome.com/file/2023/30/a270159_0s.png)
搜狗输入法如何设置字体大小?
![](https://img.aspxhome.com/file/2023/5/a318053_0s.jpg)