提示:其它语言是由 Google 机器翻译的。 你可以访问 English 版本。
登录
x
or
x
x
马上登记
x

or

如何保持excel窗口始终在最前面?

你有没有希望保持你的Excel窗口始终位于顶端,而不被其他窗口覆盖? 不幸的是,Excel不提供解决此任务的功能。 但是,在这里,我可以给你一个VBA代码来处理这个工作。

使用VBA代码始终保持Excel窗口在最前面


箭头蓝色右泡 使用VBA代码始终保持Excel窗口在最前面


以下VBA代码可以帮助您始终将Excel窗口保持在最前,该代码适用于办公室32位和办公室64位。

1。 按住 ALT + F11 键打开 Microsoft Visual Basic for Applications窗口.

2。 点击 插页 > 模块,并将以下代码粘贴到 模块窗口.

VBA代码:保持Excel窗口始终位于顶部

'Update 20140909
#If Win64 Then
    Public Declare PtrSafe Function SetWindowPos _
        Lib "user32" ( _
            ByVal hwnd As LongPtr, _
            ByVal hwndInsertAfter As LongPtr, _
            ByVal x As Long, ByVal y As Long, _
            ByVal cx As Long, ByVal cy As Long, _
            ByVal wFlags As Long) _
    As Long
#Else
    Public Declare Function SetWindowPos _
        Lib "user32" ( _
            ByVal hwnd As Long, _
            ByVal hwndInsertAfter As Long, _
            ByVal x As Long, ByVal y As Long, _
            ByVal cx As Long, ByVal cy As Long, _
            ByVal wFlags As Long) _
    As Long
#End If
Public Const SWP_NOSIZE = &H1
Public Const SWP_NOMOVE = &H2
Public Const HWND_TOPMOST = -1
Public Const HWND_NOTOPMOST = -2
Sub ShowXLOnTop(ByVal OnTop As Boolean)
    Dim xStype As Long
    #If Win64 Then
        Dim xHwnd As LongPtr
    #Else
        Dim xHwnd As Long
    #End If
    If OnTop Then
        xStype = HWND_TOPMOST
    Else
        xStype = HWND_NOTOPMOST
    End If
    Call SetWindowPos(Application.hwnd, xStype, 0, 0, 0, 0, SWP_NOSIZE Or SWP_NOMOVE)
End Sub
Sub SetXLOnTop()
    ShowXLOnTop True
End Sub
Sub SetXLNormal()
    ShowXLOnTop False
End Sub

3。 然后按 F5 运行这个代码的关键,和一个 对话框会出现,选择 SetXLOnTop 选项,然后单击 按钮。

DOC-保Excel的上顶1

4. 然后您的Excel窗口将始终位于其他应用程序之上。

注意:如果您想要使Excel窗口恢复正常,请按 F5 键打开 对话框,选择 SetXNormal 并点击 .


Kutools for Excel - 最佳办公生产力工具提高80%的生产力

  • 重用: 快速插入 复杂的公式,图表 以及你以前用过的任何东西; 加密单元格 密码; 创建邮件列表 并发送电子邮件...
  • 超级方程式酒吧 (轻松编辑多行文字和公式); 阅读布局 (轻松读取和编辑大量单元格); 粘贴到过滤范围...
  • 合并单元格/行/列 不丢失数据; 分裂细胞含量; 组合重复的行/列...防止重复的细胞; 比较范围...
  • 选择复制或唯一 行; 选择空行 (所有细胞都是空的); 超级查找和模糊查找 在许多工作簿中; 随机选择......
  • 精确复制 多个单元格而不更改公式参考; 自动创建参考 多张表; 插入项目符号,复选框等等......
  • 提取文本,添加文本,按位置删除, 删除空间; 创建和打印分页小计; 在单元格内容和注释之间转换...
  • 超级过滤器 (将过滤方案保存并应用到其他工作表); 高级排序 按月/周/日,频率等; 特殊过滤器 用粗体,斜体......
  • 结合工作簿和工作表; 根据键列合并表; 将数据拆分为多个表格; 批量转换xls,xlsx和PDF...
  • 超过300强大的功能。 支持Office / Excel 2007-2019和365。 支持所有语言。 在您的企业或组织中轻松部署。 全功能60天免费试用。
kte tab 201905

Office选项卡为Office提供选项卡式界面,使您的工作更轻松

  • 在Word,Excel,PowerPoint中启用选项卡式编辑和阅读,Publisher,Access,Visio和Project。
  • 在同一窗口的新选项卡中打开并创建多个文档,而不是在新窗口中。
  • 通过50%提高您的工作效率,每天为您减少数百次鼠标点击!
官方底部
Say something here...
symbols left.
You are guest ( Sign Up? )
or post as a guest, but your post won't be published automatically.
Loading comment... The comment will be refreshed after 00:00.
  • To post as a guest, your comment is unpublished.
    Freediv · 1 years ago
    Hello

    It seems that xHwnd defined to store Application.hWnd before calling SetWindowPos as below:

    xHwnd = Application.hWnd
    Call SetWindowPos(xHwnd, xStype, 0, 0, 0, 0, SWP_NOSIZE Or SWP_NOMOVE)

    Thanks
  • To post as a guest, your comment is unpublished.
    Prof. LI · 1 years ago
    Absolute genius. Exactly what I needed. Thanks!!!
  • To post as a guest, your comment is unpublished.
    David Conger-Eldeen · 1 years ago
    Thanks so much for this! I needed to keep my automated system stats sheet up at all times while I did other things based on what it was showing me. Very helpfull! :D
  • To post as a guest, your comment is unpublished.
    Kels · 2 years ago
    Thanks .. God Bless..!
  • To post as a guest, your comment is unpublished.
    Sam · 3 years ago
    Thanks for this. Very helpful when transposing data from multiple systems onto a spread sheet. Appreciate the code!
  • To post as a guest, your comment is unpublished.
    Clark · 3 years ago
    Thanks for the help!!! I had to use this as a workaround because you cant have two workpages open at the same time. Appreciate you sharing your code :)
  • To post as a guest, your comment is unpublished.
    Eric H · 5 years ago
    Love this!! Great code. Thanks! I'm a beginning programmer, I just barely know what it does.

    Where would I change in the code if I wanted the window to jump to a certain size, hide the ribbon, and/or jump to a certain sheet or cell range?
  • To post as a guest, your comment is unpublished.
    JennyRae · 5 years ago
    Thanks for providing this code! So helpful. I've been using Judy ten key for this feature but now I can use excel. Awesome, thank you!!